Files
Compass/tests/e2e/web/fixtures/base.ts
MartinBraquet 309cbe7f2b Use unique user ID for each e2e test to fix race condition
Before, each test would delete all existing users—including the ones still used in concurrent tests
2026-02-28 14:37:43 +01:00

62 lines
1.9 KiB
TypeScript

import {test as base} from '@playwright/test'
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 {onboarding, OnboardingUser} from '../utils/accountInformation'
import {deleteUser} from '../utils/deleteUser'
export const test = base.extend<{
homePage: HomePage
onboardingPage: OnboardingPage
signUpPage: SignUpPage
profilePage: ProfilePage
authPage: AuthPage
cleanUpUsers: void
testAccount: OnboardingUser
fakerAccount: OnboardingUser
}>({
testAccount: async ({}, use) => {
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) => {
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)
await use(onboardingPage)
},
homePage: async ({page}, use) => {
const homePage = new HomePage(page)
await use(homePage)
},
signUpPage: async ({page}, use) => {
const signUpPage = new SignUpPage(page)
await use(signUpPage)
},
authPage: async ({page}, use) => {
const authPage = new AuthPage(page)
await use(authPage)
},
profilePage: async ({page}, use) => {
const profilePage = new ProfilePage(page)
await use(profilePage)
},
// cleanUpUsers: [
// async ({}, use) => {
// await use()
// },
// {auto: true},
// ],
})
export {expect} from '@playwright/test'