From 1d898f34fcce78ef779b8d91952531735feaf947 Mon Sep 17 00:00:00 2001 From: Okechi Jones-Williams Date: Fri, 3 Apr 2026 20:57:40 +0100 Subject: [PATCH] Changes requested --- playwright.config.ts | 9 ++++---- tests/e2e/web/pages/authPage.ts | 6 ++---- tests/e2e/web/specs/onboardingFlow.spec.ts | 24 ++++++---------------- tests/e2e/web/utils/deleteUser.ts | 17 ++++++++++----- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index cfc503d9..a2a6726c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -25,12 +25,11 @@ function getSupabaseEnv() { } } -if (process.env.DIRECT_SUPABASE_SETUP_IN_PLAYWRIGHT !== 'false') { - const supabaseEnv = getSupabaseEnv() - // Inject into process.env so Playwright and your app code can read them - Object.assign(process.env, supabaseEnv) -} +const supabaseEnv = getSupabaseEnv() + +// Inject into process.env so Playwright and your app code can read them +Object.assign(process.env, supabaseEnv) export default defineConfig({ testDir: './tests/e2e', diff --git a/tests/e2e/web/pages/authPage.ts b/tests/e2e/web/pages/authPage.ts index e1874122..7bccdf38 100644 --- a/tests/e2e/web/pages/authPage.ts +++ b/tests/e2e/web/pages/authPage.ts @@ -55,10 +55,8 @@ export class AuthPage { await popup.getByLabel('Email').fill(email) if (display_name) await popup.getByLabel('Display name').fill(display_name) if (username) await popup.getByLabel('Screen name', {exact: true}).fill(username) - await Promise.all([ - // popup.waitForEvent('close'), - popup.getByText('Sign in with Google.com', {exact: true}).click(), - ]) + await popup.getByText('Sign in with Google.com', {exact: true}).click() + await popup.waitForEvent('close') } async clickSignUpWithEmailButton() { diff --git a/tests/e2e/web/specs/onboardingFlow.spec.ts b/tests/e2e/web/specs/onboardingFlow.spec.ts index a9a5cc5c..3f49f522 100644 --- a/tests/e2e/web/specs/onboardingFlow.spec.ts +++ b/tests/e2e/web/specs/onboardingFlow.spec.ts @@ -212,7 +212,7 @@ test.describe('when given valid input', () => { onboardingAccount.alcohol_consumed_per_month, ) }) - + test('should successfully complete the onboarding flow with google account', async ({ app, googleAccountOne, @@ -272,11 +272,7 @@ test.describe('when given valid input', () => { await expect(dbInfo.user.name).toContain(fakerAccount.display_name) await expect(dbInfo.user.username).toContain(fakerAccount.username) - await homePage.clickSettingsLink() - await settingsPage.clickDeleteAccountButton() - await settingsPage.fillDeleteAccountSurvey('Delete me') - await settingsPage.clickDeleteAccountButton() - await homePage.verifyHomePageLinks() + await deleteProfileFromSettings(homePage, settingsPage) }) test('should successfully delete an account created via google auth', async ({ @@ -287,10 +283,12 @@ test.describe('when given valid input', () => { profilePage, settingsPage, googleAccountTwo, + headless, }) => { console.log( `Starting "should successfully delete an account created via google auth" with ${googleAccountTwo.username}`, ) + test.skip(headless, 'Google popup auth test requires headed mode') await homePage.goToRegisterPage() await authPage.fillPasswordField('') //The test only passes when this is added...something is weird here await authPage.signInToGoogleAccount( @@ -298,13 +296,7 @@ test.describe('when given valid input', () => { googleAccountTwo.display_name, googleAccountTwo.username, ) - await onboardingPage.clickSkipOnboardingButton() - await signUpPage.fillDisplayName(googleAccountTwo.display_name) - await signUpPage.fillUsername(googleAccountTwo.username) - await signUpPage.clickNextButton() - await signUpPage.clickNextButton() //Skip optional information - await profilePage.clickCloseButton() - await onboardingPage.clickRefineProfileButton() + await skipOnboardingHeadToProfile(onboardingPage, signUpPage, profilePage, googleAccountTwo) //Verify displayed information is correct await profilePage.verifyDisplayName(googleAccountTwo.display_name) @@ -315,11 +307,7 @@ test.describe('when given valid input', () => { await expect(dbInfo.user.name).toContain(googleAccountTwo.display_name) await expect(dbInfo.user.username).toContain(googleAccountTwo.username) - await homePage.clickSettingsLink() - await settingsPage.clickDeleteAccountButton() - await settingsPage.fillDeleteAccountSurvey('Delete me') - await settingsPage.clickDeleteAccountButton() - await homePage.verifyHomePageLinks() + await deleteProfileFromSettings(homePage, settingsPage) }) test('should successfully enter optional information after completing flow', async ({ diff --git a/tests/e2e/web/utils/deleteUser.ts b/tests/e2e/web/utils/deleteUser.ts index d7376fe3..ed088fac 100644 --- a/tests/e2e/web/utils/deleteUser.ts +++ b/tests/e2e/web/utils/deleteUser.ts @@ -1,5 +1,5 @@ -import {deleteFromDb} from '../../utils/databaseUtils' -import {deleteAccount, firebaseLoginEmailPassword} from '../../utils/firebaseUtils' +import {deleteFromDb, userInformationFromDb} from '../../utils/databaseUtils' +import {deleteAccount, firebaseLoginEmailPassword, findUser} from '../../utils/firebaseUtils' import {UserAccountInformation} from './accountInformation' import {AuthObject} from './networkUtils' @@ -13,9 +13,16 @@ export async function deleteUser( let loginInfo if (authType === 'Email/Password') { loginInfo = await firebaseLoginEmailPassword(account?.email, account?.password) - await deleteAccount(loginInfo?.data.idToken) - await deleteFromDb(loginInfo?.data.localId) - } else if (authType === 'Google' && authInfo) { + try { + await deleteAccount(loginInfo?.data.idToken) + const userDbCheck = await userInformationFromDb(account) + if (userDbCheck) { + await deleteFromDb(loginInfo?.data.localId) + } + } catch (dbError) {} + }else if (authType === 'Google' && authInfo) { + const googleAuthUser = await findUser(authInfo.idToken) + if (!googleAuthUser) return await deleteAccount(authInfo.idToken) await deleteFromDb(authInfo.localId) }