From a2894a9d5e040df878a68e55bdf5767e615b6230 Mon Sep 17 00:00:00 2001 From: Sergey Garin Date: Wed, 22 May 2024 18:58:52 +0300 Subject: [PATCH] fixes in tests --- app/ide-desktop/lib/dashboard/e2e/actions.ts | 21 ++++++++++++------- .../src/modals/TermsOfServiceModal.tsx | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/ide-desktop/lib/dashboard/e2e/actions.ts b/app/ide-desktop/lib/dashboard/e2e/actions.ts index 78e2cfeb22823..43f1604f68a99 100644 --- a/app/ide-desktop/lib/dashboard/e2e/actions.ts +++ b/app/ide-desktop/lib/dashboard/e2e/actions.ts @@ -789,14 +789,19 @@ async function mockDate({ page }: MockParams) { /** * Passes Terms and conditions dialog - * @param page */ -export async function passTermsAndConditionsDialog({page}: MockParams) { - await page.waitForSelector('', { - state: 'attached' - }) - - +export async function passTermsAndConditionsDialog({ page }: MockParams) { + // wait for terms and conditions dialog to appear + // but don't fail if it doesn't appear + try { + // wait for terms and conditions dialog to appear + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + await page.waitForSelector('#terms-of-service-modal', { timeout: 500 }) + await page.getByRole('checkbox').click() + await page.getByRole('button', { name: 'Accept' }).click() + } catch (error) { + // do nothing + } } // ======================== @@ -849,6 +854,8 @@ export async function mockAllAndLogin({ page }: MockParams) { const mocks = await mockAll({ page }) await login({ page }) + await passTermsAndConditionsDialog({ page }) + // This MUST run after login, otherwise the element's styles are reset when the browser // is navigated to another page. await mockIDEContainer({ page }) diff --git a/app/ide-desktop/lib/dashboard/src/modals/TermsOfServiceModal.tsx b/app/ide-desktop/lib/dashboard/src/modals/TermsOfServiceModal.tsx index 7a333d0bd993f..121275a6fb431 100644 --- a/app/ide-desktop/lib/dashboard/src/modals/TermsOfServiceModal.tsx +++ b/app/ide-desktop/lib/dashboard/src/modals/TermsOfServiceModal.tsx @@ -80,12 +80,14 @@ export function TermsOfServiceModal() { hideCloseButton modalProps={{ isOpen: true }} testId="terms-of-service-modal" + id="terms-of-service-modal" > value, getText('licenseAgreementCheckboxError')), })} onSubmit={() => {