mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-04 23:03:45 -04:00
* Added Database checks to the onboarding flow * Added compatibility page setup Added more compatibility questions * Finished up the onboarding flow suite Added compatibility question tests and verifications Updated tests to cover Keywords and Headline changes recently made Updated tests to cover all of the big5 personality traits * . * Fix: Merge conflict * . * Fix: Added fix for None discriptive error issue #36 Updated signUp.spec.ts to use new fixture Updated Account information variable names Deleted "deleteUserFixture.ts" as it was incorporated into the "base.ts" file * Linting and Prettier * Minor cleaning * Organizing helper func * Added Google account to the Onboarding flow * . * Added account cleanup for google accounts * Started work on Sign-in tests Updated seedDatabase.ts to throw an error if the user already exists, to also add display names and usernames so they seedUser func acts like a normal basic user Some organising of the google auth code * Linting and Prettier * Added checks to the deleteUser func to check if the accout exists Added account deletion checks * Linting and Prettier * Added POM's for social and organisation page Updated settings POM * Formatting update, fixed homePage locator for signin * . * . * . * Coderabbitai fix's * Fix * Improve test utilities and stabilize onboarding flow tests * Changes requested * Seperated deletion tests from onboarding * Update `.coderabbit.yaml` with improved internationalization guidance and formatting adjustments * Clean up `.vscode/settings.json` and add it to `.gitignore` * Add Playwright E2E test guidelines to `.coderabbit.yaml` * Standardize and improve formatting in `TESTING.md` for better readability and consistency. * Refactor onboarding flow tests and related utilities; improve formatting and remove redundant tests. --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import axios from 'axios'
|
|
|
|
import {config} from '../web/SPEC_CONFIG'
|
|
|
|
export async function firebaseLoginEmailPassword(
|
|
email: string | undefined,
|
|
password: string | undefined,
|
|
) {
|
|
const login = await axios.post(
|
|
`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.SIGN_IN_PASSWORD}`,
|
|
{
|
|
email,
|
|
password,
|
|
returnSecureToken: true,
|
|
},
|
|
)
|
|
return login
|
|
}
|
|
|
|
export async function getUserId(email: string, password: string) {
|
|
try {
|
|
const loginInfo = await firebaseLoginEmailPassword(email, password)
|
|
return loginInfo.data.localId
|
|
} catch {
|
|
return
|
|
}
|
|
}
|
|
|
|
export async function findUser(idToken: string) {
|
|
const response = await axios.post(
|
|
`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.ACCOUNT_LOOKUP}`,
|
|
{
|
|
idToken,
|
|
},
|
|
)
|
|
if (response?.data?.users?.length > 0) {
|
|
return response.data.users[0]
|
|
}
|
|
}
|
|
|
|
export async function firebaseSignUp(email: string, password: string) {
|
|
try {
|
|
const response = await axios.post(`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.SIGNUP}`, {
|
|
email,
|
|
password,
|
|
returnSecureToken: true,
|
|
})
|
|
const userId = response.data.localId
|
|
console.log('User created in Firebase Auth:', {email, userId})
|
|
return userId
|
|
} catch (err: any) {
|
|
if (
|
|
err.response?.status === 400 ||
|
|
err.response?.data?.error?.message?.includes('EMAIL_EXISTS')
|
|
) {
|
|
return await getUserId(email, password)
|
|
}
|
|
if (err.code === 'ECONNREFUSED') return
|
|
// throw Error('Firebase emulator not running. Start it with:\n yarn test:e2e:services\n')
|
|
console.log(err)
|
|
throw err
|
|
}
|
|
}
|
|
|
|
export async function deleteAccount(idToken: any) {
|
|
try {
|
|
await axios.post(`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.DELETE}`, {
|
|
idToken: idToken,
|
|
})
|
|
} catch (err: any) {
|
|
if (err.response?.data?.error?.message?.includes('USER_NOT_FOUND')) {
|
|
return
|
|
}
|
|
throw err
|
|
}
|
|
}
|