Skip to content

Commit 536f23a

Browse files
committed
Wait for page hydration
1 parent 7658842 commit 536f23a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

frontend/test/playwright/visual-regression/pages/errors.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect } from "@playwright/test"
12
import { test } from "~~/test/playwright/utils/test"
23
import breakpoints from "~~/test/playwright/utils/breakpoints"
34
import {
@@ -6,7 +7,8 @@ import {
67
sleep,
78
} from "~~/test/playwright/utils/navigation"
89
import { setViewportToFullHeight } from "~~/test/playwright/utils/viewport"
9-
import { languageDirections } from "~~/test/playwright/utils/i18n"
10+
import { languageDirections, t } from "~~/test/playwright/utils/i18n"
11+
import { getH1 } from "~~/test/playwright/utils/components"
1012

1113
import { ALL_MEDIA, supportedSearchTypes } from "#shared/constants/media"
1214

@@ -56,6 +58,7 @@ breakpoints.describeXl(({ breakpoint, expectSnapshot }) => {
5658
// eslint-disable-next-line playwright/no-networkidle
5759
await page.waitForLoadState("networkidle")
5860

61+
await expect(getH1(page, t("404.title"))).toBeVisible()
5962
await expectSnapshot(page, "generic-error-ltr", page, {
6063
screenshotOptions: { fullPage: true },
6164
})
@@ -77,6 +80,7 @@ for (const searchType of supportedSearchTypes) {
7780
await preparePageForTests(page, breakpoint)
7881
await goToSearchTerm(page, `SearchPage500error`, { searchType })
7982

83+
await expect(getH1(page, t("404.title"))).toBeVisible()
8084
await expectSnapshot(page, "generic-error-ltr", page, {
8185
screenshotOptions: { fullPage: true },
8286
})
@@ -101,6 +105,7 @@ for (const searchType of supportedSearchTypes) {
101105
searchType,
102106
})
103107

108+
await expect(getH1(page, t("404.title"))).toBeVisible()
104109
await expectSnapshot(page, "generic-error", page, {
105110
dir,
106111
screenshotOptions: {
@@ -136,6 +141,8 @@ for (const searchType of supportedSearchTypes) {
136141
})
137142
await goToSearchTerm(page, "cat", { dir, searchType, mode: "CSR" })
138143

144+
await expect(getH1(page, t("serverTimeout.heading", dir))).toBeVisible()
145+
139146
await setViewportToFullHeight(page)
140147

141148
await page.mouse.move(0, 82)

frontend/test/playwright/visual-regression/pages/pages.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from "@playwright/test"
22
import { test } from "~~/test/playwright/utils/test"
33
import breakpoints from "~~/test/playwright/utils/breakpoints"
44
import {
5+
isPageDesktop,
56
pathWithDir,
67
preparePageForTests,
78
} from "~~/test/playwright/utils/navigation"
@@ -11,6 +12,7 @@ import {
1112
getHomepageSearchButton,
1213
getLanguageSelect,
1314
getLoadMoreButton,
15+
getMenuButton,
1416
} from "~~/test/playwright/utils/components"
1517

1618
test.describe.configure({ mode: "parallel" })
@@ -32,6 +34,11 @@ for (const contentPage of contentPages) {
3234

3335
await page.goto(pathWithDir(contentPage, dir))
3436
// Ensure the page is hydrated
37+
// eslint-disable-next-line playwright/no-conditional-in-test
38+
if (!isPageDesktop(page)) {
39+
// eslint-disable-next-line playwright/no-conditional-expect
40+
await expect(getMenuButton(page, dir)).toBeEnabled()
41+
}
3542
await expect(page.locator("#language")).toHaveValue(
3643
dir === "ltr" ? "en" : "ar"
3744
)

0 commit comments

Comments
 (0)