mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-23 18:36:02 -05:00
* . * Centralizing config details * Added data-testId attributes where necessary and started the onboarding flow scaffolding * Continued onboarding test scaffolding * Continued work on tests for the Onboarding flow * . * Updated "Want kids" options to be less flaky Updated playwright.config so that expect timeout matching test timeout * Continued updating front-end scaffolding * . * . * . * . * Updated fixture function deleteUser: to also remove the database user information * Rm * Fix * Fixes --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import axios from 'axios';
|
|
import { createSupabaseDirectClient } from "../../../../backend/shared/src/supabase/init";
|
|
import { config } from '../SPEC_CONFIG';
|
|
|
|
export async function deleteUser(email: string, password: string) {
|
|
|
|
try {
|
|
const login = await axios.post(
|
|
`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.SIGN_IN_PASSWORD}`,
|
|
{
|
|
email,
|
|
password,
|
|
returnSecureToken: true
|
|
}
|
|
);
|
|
|
|
await deleteFromDb(login.data.localId);
|
|
|
|
await axios.post(
|
|
`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.DELETE}`,
|
|
{ idToken: login.data.idToken }
|
|
);
|
|
|
|
|
|
} catch (err: any) {
|
|
console.log(err);
|
|
}
|
|
};
|
|
|
|
async function deleteFromDb(user_id: string) {
|
|
const db = createSupabaseDirectClient();
|
|
try {
|
|
const deleteEntryById = `DELETE FROM users WHERE id = $1 RETURNING *`;
|
|
const result = await db.query(deleteEntryById, [user_id]);
|
|
console.log("Deleted data: ",{
|
|
"id": result[0].id,
|
|
"name": result[0].name,
|
|
"username": result[0].username
|
|
});
|
|
} catch (error) {
|
|
console.error("Failed to delete user data, all changes rolled back: ", error);
|
|
throw error;
|
|
};
|
|
}; |