From 492ee7a737debb74fe9adc43c7140f4d6525381f Mon Sep 17 00:00:00 2001 From: Okechi Jones-Williams Date: Thu, 2 Apr 2026 23:10:31 +0100 Subject: [PATCH] Coderabbitai fix's --- tests/e2e/web/pages/authPage.ts | 6 ++-- tests/e2e/web/utils/testCleanupHelpers.ts | 34 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/e2e/web/utils/testCleanupHelpers.ts diff --git a/tests/e2e/web/pages/authPage.ts b/tests/e2e/web/pages/authPage.ts index 7bccdf38..c4f82b94 100644 --- a/tests/e2e/web/pages/authPage.ts +++ b/tests/e2e/web/pages/authPage.ts @@ -55,8 +55,10 @@ 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 popup.getByText('Sign in with Google.com', {exact: true}).click() - await popup.waitForEvent('close') + await Promise.all([ + popup.waitForEvent('close'), + popup.getByText('Sign in with Google.com', {exact: true}).click(), + ]) } async clickSignUpWithEmailButton() { diff --git a/tests/e2e/web/utils/testCleanupHelpers.ts b/tests/e2e/web/utils/testCleanupHelpers.ts new file mode 100644 index 00000000..cff9f47a --- /dev/null +++ b/tests/e2e/web/utils/testCleanupHelpers.ts @@ -0,0 +1,34 @@ +import {AuthPage} from '../pages/AuthPage' +import {HomePage} from '../pages/homePage' +import {UserAccountInformation} from '../utils/accountInformation' + +export async function registerWithEmail( + homePage: HomePage, + authPage: AuthPage, + account: UserAccountInformation, +) { + await homePage.goToRegisterPage() + await authPage.fillEmailField(account.email) + await authPage.fillPasswordField(account.password) + await authPage.clickSignUpWithEmailButton() +} + +export async function signinWithEmail( + homePage: HomePage, + authPage: AuthPage, + accountOrEmail: UserAccountInformation | string, + password?: string, +) { + const email = typeof accountOrEmail === 'string' ? accountOrEmail : accountOrEmail.email + + const resolvedPassword = typeof accountOrEmail === 'string' ? password : accountOrEmail.password + + if (!email || !resolvedPassword) { + throw new Error('Provide either an `account` or `email` and `password`.') + } + + await homePage.goToSigninPage() + await authPage.fillEmailField(email) + await authPage.fillPasswordField(resolvedPassword) + await authPage.clickSignInWithEmailButton() +}