From 56bbb8fc1b703a522919fb368acff3543c6ee848 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Mon, 16 Dec 2024 16:18:27 +0300 Subject: [PATCH] Wait for page hydration --- .../playwright/visual-regression/pages/errors.spec.ts | 9 ++++++++- .../playwright/visual-regression/pages/pages.spec.ts | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/test/playwright/visual-regression/pages/errors.spec.ts b/frontend/test/playwright/visual-regression/pages/errors.spec.ts index c847e2c3a7d..f0d103ab2df 100644 --- a/frontend/test/playwright/visual-regression/pages/errors.spec.ts +++ b/frontend/test/playwright/visual-regression/pages/errors.spec.ts @@ -1,3 +1,4 @@ +import { expect } from "@playwright/test" import { test } from "~~/test/playwright/utils/test" import breakpoints from "~~/test/playwright/utils/breakpoints" import { @@ -6,7 +7,8 @@ import { sleep, } from "~~/test/playwright/utils/navigation" import { setViewportToFullHeight } from "~~/test/playwright/utils/viewport" -import { languageDirections } from "~~/test/playwright/utils/i18n" +import { languageDirections, t } from "~~/test/playwright/utils/i18n" +import { getH1 } from "~~/test/playwright/utils/components" import { ALL_MEDIA, supportedSearchTypes } from "#shared/constants/media" @@ -56,6 +58,7 @@ breakpoints.describeXl(({ breakpoint, expectSnapshot }) => { // eslint-disable-next-line playwright/no-networkidle await page.waitForLoadState("networkidle") + await expect(getH1(page, t("404.title"))).toBeVisible() await expectSnapshot(page, "generic-error-ltr", page, { screenshotOptions: { fullPage: true }, }) @@ -77,6 +80,7 @@ for (const searchType of supportedSearchTypes) { await preparePageForTests(page, breakpoint) await goToSearchTerm(page, `SearchPage500error`, { searchType }) + await expect(getH1(page, t("404.title"))).toBeVisible() await expectSnapshot(page, "generic-error-ltr", page, { screenshotOptions: { fullPage: true }, }) @@ -101,6 +105,7 @@ for (const searchType of supportedSearchTypes) { searchType, }) + await expect(getH1(page, t("404.title"))).toBeVisible() await expectSnapshot(page, "generic-error", page, { dir, screenshotOptions: { @@ -136,6 +141,8 @@ for (const searchType of supportedSearchTypes) { }) await goToSearchTerm(page, "cat", { dir, searchType, mode: "CSR" }) + await expect(getH1(page, t("serverTimeout.heading", dir))).toBeVisible() + await setViewportToFullHeight(page) await page.mouse.move(0, 82) diff --git a/frontend/test/playwright/visual-regression/pages/pages.spec.ts b/frontend/test/playwright/visual-regression/pages/pages.spec.ts index 650688e879d..5c66041f4a5 100644 --- a/frontend/test/playwright/visual-regression/pages/pages.spec.ts +++ b/frontend/test/playwright/visual-regression/pages/pages.spec.ts @@ -2,6 +2,7 @@ import { expect } from "@playwright/test" import { test } from "~~/test/playwright/utils/test" import breakpoints from "~~/test/playwright/utils/breakpoints" import { + isPageDesktop, pathWithDir, preparePageForTests, } from "~~/test/playwright/utils/navigation" @@ -11,6 +12,7 @@ import { getHomepageSearchButton, getLanguageSelect, getLoadMoreButton, + getMenuButton, } from "~~/test/playwright/utils/components" test.describe.configure({ mode: "parallel" }) @@ -32,6 +34,11 @@ for (const contentPage of contentPages) { await page.goto(pathWithDir(contentPage, dir)) // Ensure the page is hydrated + // eslint-disable-next-line playwright/no-conditional-in-test + if (!isPageDesktop(page)) { + // eslint-disable-next-line playwright/no-conditional-expect + await expect(getMenuButton(page, dir)).toBeEnabled() + } await expect(page.locator("#language")).toHaveValue( dir === "ltr" ? "en" : "ar" )