Changes requested

This commit is contained in:
Okechi Jones-Williams
2026-04-03 20:57:40 +01:00
parent 7daf458001
commit 1d898f34fc
4 changed files with 24 additions and 32 deletions

View File

@@ -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',

View File

@@ -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() {

View File

@@ -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 ({

View File

@@ -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)
}