diff --git a/tests/e2e/web/fixtures/base.ts b/tests/e2e/web/fixtures/base.ts index a1ad6fb4..6c8a43e6 100644 --- a/tests/e2e/web/fixtures/base.ts +++ b/tests/e2e/web/fixtures/base.ts @@ -1,11 +1,12 @@ import {test as base} from '@playwright/test' -import {deleteUser} from '../utils/deleteUser' -import {onboarding, OnboardingUser} from '../utils/accountInformation' -import {OnboardingPage} from '../pages/onboardingPage' + +import {AuthPage} from '../pages/AuthPage' import {HomePage} from '../pages/homePage' +import {OnboardingPage} from '../pages/onboardingPage' import {ProfilePage} from '../pages/profilePage' import {SignUpPage} from '../pages/signUpPage' -import {AuthPage} from '../pages/AuthPage' +import {onboarding, OnboardingUser} from '../utils/accountInformation' +import {deleteUser} from '../utils/deleteUser' export const test = base.extend<{ homePage: HomePage @@ -18,10 +19,16 @@ export const test = base.extend<{ fakerAccount: OnboardingUser }>({ testAccount: async ({}, use) => { - await use(onboarding.account_one) + const account = onboarding.account_one() // email captured here + await use(account) + console.log('Cleaning up onboarding 1 account...') + await deleteUser(account.email, account.password) // same account, guaranteed }, fakerAccount: async ({}, use) => { - await use(onboarding.faker_account) + const account = onboarding.faker_account() // email captured here + await use(account) + console.log('Cleaning up faker account...') + await deleteUser(account.email, account.password) // same account, guaranteed }, onboardingPage: async ({page}, use) => { const onboardingPage = new OnboardingPage(page) @@ -43,14 +50,12 @@ export const test = base.extend<{ const profilePage = new ProfilePage(page) await use(profilePage) }, - cleanUpUsers: [ - async ({}, use) => { - await use() - await deleteUser(onboarding.account_one.email, onboarding.account_one.password) - await deleteUser(onboarding.faker_account.email, onboarding.faker_account.password) - }, - {auto: true}, - ], + // cleanUpUsers: [ + // async ({}, use) => { + // await use() + // }, + // {auto: true}, + // ], }) export {expect} from '@playwright/test' diff --git a/tests/e2e/web/utils/accountInformation.ts b/tests/e2e/web/utils/accountInformation.ts index 6dad4fd6..d84767af 100644 --- a/tests/e2e/web/utils/accountInformation.ts +++ b/tests/e2e/web/utils/accountInformation.ts @@ -1,21 +1,22 @@ import {faker} from '@faker-js/faker' + import { + Causes, + ChildrenExpectation, ConnectionType, + Diet, + Education, Ethnicity, Gender, InterestedIn, + Interests, + Language, + Personality, + Platforms, + PoliticalBeliefs, RelationshipStatus, RelationshipStyle, - ChildrenExpectation, - Interests, - Causes, - Education, - PoliticalBeliefs, Religion, - Personality, - Diet, - Language, - Platforms, } from '../pages/signUpPage' export type OnboardingUser = { @@ -84,26 +85,29 @@ type FiveBigPersonalityTraits = { conscientiousness?: number extraversion?: number agreeableness?: number - neutroticism?: number + neuroticism?: number } type OnboardingConfig = { - faker_account: OnboardingUser - account_one: OnboardingUser + faker_account: () => OnboardingUser + account_one: () => OnboardingUser } export const onboarding: OnboardingConfig = { - faker_account: { - email: faker.internet.email(), + // Use a function so email is unique per test call + faker_account: () => ({ + email: `faker+${crypto.randomUUID()}@test.com`, password: faker.internet.password(), display_name: faker.internet.displayName(), - username: faker.internet.username(), - }, - account_one: { - email: 'onboardingOne@compass.com', + username: `user_${crypto.randomUUID().slice(0, 8)}`, + }), + + account_one: () => ({ + // Use a non-real TLD like @test.compass to make it obvious these are test accounts and prevent accidental emails + email: `onboarding+${crypto.randomUUID()}@test.compass`, password: 'CompassTest', display_name: 'Compass Onboarding', - username: 'TheGreatOnboarding', + username: `TheGreatOnboarding_${crypto.randomUUID().slice(0, 8)}`, bio: 'Born beneath twin moons, this wanderer maps forgotten roads, trades riddles for shelter, and keeps stories in glass bottles. Drawn to ancient libraries and glowing forests, they seek lost spells, quiet taverns, and adventures that rewrite fate. Their compass points to wonder. Ever onward. Always. Go', gender: 'Woman', age: '25', @@ -154,5 +158,5 @@ export const onboarding: OnboardingConfig = { urlOrUsername: 'TheGreatConnection', }, ], - }, + }), } diff --git a/tests/e2e/web/utils/deleteUser.ts b/tests/e2e/web/utils/deleteUser.ts index a8bd5ec5..516956eb 100644 --- a/tests/e2e/web/utils/deleteUser.ts +++ b/tests/e2e/web/utils/deleteUser.ts @@ -1,5 +1,6 @@ import axios from 'axios' -import {createSupabaseDirectClient} from '../../../../backend/shared/src/supabase/init' +import {createSupabaseDirectClient} from 'shared/supabase/init' + import {config} from '../SPEC_CONFIG' export async function deleteUser(email: string, password: string) { @@ -19,6 +20,14 @@ export async function deleteUser(email: string, password: string) { idToken: login.data.idToken, }) } catch (err: any) { + // Skip deletion if user doesn't exist or other auth errors occur + if ( + err.response?.status === 400 || + err.response?.data?.error?.message?.includes('EMAIL_NOT_FOUND') + ) { + console.log(`Email not found, skipping user deletion for ${email}`) + return + } console.log(err) } }