Fix E2E tests

This commit is contained in:
somebody1234 2024-08-14 21:09:08 +10:00
parent e70c749d13
commit 8dcdc91653
7 changed files with 23 additions and 14 deletions

View File

@ -765,7 +765,7 @@ export async function login(
await locateLoginButton(page).click()
await test.expect(page.getByText('Logging in to Enso...')).not.toBeVisible()
if (first) {
await passTermsAndConditionsDialog({ page, setupAPI })
await passAgreementsDialog({ page, setupAPI })
await test.expect(page.getByText('Logging in to Enso...')).not.toBeVisible()
}
})
@ -840,11 +840,12 @@ async function mockDate({ page }: MockParams) {
})
}
/** Pass the Terms and conditions dialog. */
export async function passTermsAndConditionsDialog({ page }: MockParams) {
/** Pass the Agreements dialog. */
export async function passAgreementsDialog({ page }: MockParams) {
await test.test.step('Accept Terms and Conditions', async () => {
await page.waitForSelector('#terms-of-service-modal')
await page.getByRole('checkbox').click()
await page.waitForSelector('#agreements-modal')
await page.getByRole('checkbox').and(page.getByTestId('terms-of-service-checkbox')).click()
await page.getByRole('checkbox').and(page.getByTestId('privacy-policy-checkbox')).click()
await page.getByRole('button', { name: 'Accept' }).click()
})
}

View File

@ -83,6 +83,14 @@ export default class RegisterPageActions extends BaseActions {
await this.page.getByPlaceholder(TEXT.emailPlaceholder).fill(email)
await this.page.getByPlaceholder(TEXT.passwordPlaceholder).fill(password)
await this.page.getByPlaceholder(TEXT.confirmPasswordPlaceholder).fill(confirmPassword)
await this.page
.getByRole('checkbox')
.and(this.page.getByTestId('terms-of-service-checkbox'))
.click()
await this.page
.getByRole('checkbox')
.and(this.page.getByTestId('privacy-policy-checkbox'))
.click()
await this.page
.getByRole('button', { name: TEXT.register, exact: true })
.getByText(TEXT.register)

View File

@ -65,7 +65,7 @@ test.test('asset panel contents', ({ page }) =>
})
.login()
.do(async (thePage) => {
await actions.passTermsAndConditionsDialog({ page: thePage })
await actions.passAgreementsDialog({ page: thePage })
})
.driveTable.clickRow(0)
.toggleAssetPanel()

View File

@ -12,7 +12,7 @@ test.test('login and logout', ({ page }) =>
.mockAll({ page })
.login()
.do(async (thePage) => {
await actions.passTermsAndConditionsDialog({ page: thePage })
await actions.passAgreementsDialog({ page: thePage })
await test.expect(actions.locateDriveView(thePage)).toBeVisible()
await test.expect(actions.locateLoginButton(thePage)).not.toBeVisible()
})

View File

@ -4,7 +4,7 @@ import * as test from '@playwright/test'
import {
INVALID_PASSWORD,
mockAll,
passTermsAndConditionsDialog,
passAgreementsDialog,
TEXT,
VALID_EMAIL,
VALID_PASSWORD,
@ -26,7 +26,7 @@ test.test('login screen', ({ page }) =>
// Technically it should not be allowed, but
.login(VALID_EMAIL, INVALID_PASSWORD)
.do(async (thePage) => {
await passTermsAndConditionsDialog({ page: thePage })
await passAgreementsDialog({ page: thePage })
})
.withDriveView(async (driveView) => {
await test.expect(driveView).toBeVisible()

View File

@ -129,8 +129,8 @@ export function AgreementsModal() {
isDismissable={false}
hideCloseButton
modalProps={{ defaultOpen: true }}
testId="terms-of-service-modal"
id="terms-of-service-modal"
testId="agreements-modal"
id="agreements-modal"
>
<Form
schema={formSchema}
@ -138,7 +138,7 @@ export function AgreementsModal() {
agreedToTos: tosHash === cachedTosHash,
agreedToPrivacyPolicy: privacyPolicyHash === cachedPrivacyPolicyHash,
}}
testId="terms-of-service-form"
testId="agreements-form"
method="dialog"
onSubmit={() => {
// Only the last one in the sequence should trigger a re-render.
@ -191,7 +191,7 @@ export function AgreementsModal() {
'flex size-4 cursor-pointer overflow-clip rounded-lg border border-primary outline-primary focus-visible:outline focus-visible:outline-2',
isInvalid && 'border-red-700 text-red-500 outline-red-500',
)}
data-testid="terms-of-service-checkbox"
data-testid="privacy-policy-checkbox"
{...omit(register('agreedToPrivacyPolicy'), 'isInvalid')}
/>

View File

@ -210,7 +210,7 @@ export default function Registration() {
'flex size-4 cursor-pointer overflow-clip rounded-lg border border-primary outline-primary focus-visible:outline focus-visible:outline-2',
isInvalid && 'border-red-700 text-red-500 outline-red-500',
)}
data-testid="terms-of-service-checkbox"
data-testid="privacy-policy-checkbox"
{...omit(register('agreedToPrivacyPolicy'), 'isInvalid')}
/>