Skip to content

Commit

Permalink
Wait for page hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Dec 16, 2024
1 parent 7658842 commit 4401e95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from "@playwright/test"
import { test } from "~~/test/playwright/utils/test"
import breakpoints from "~~/test/playwright/utils/breakpoints"
import {
Expand All @@ -7,6 +8,8 @@ import {
} from "~~/test/playwright/utils/navigation"
import { setViewportToFullHeight } from "~~/test/playwright/utils/viewport"
import { languageDirections } from "~~/test/playwright/utils/i18n"
import { getH1 } from "~~/test/playwright/utils/components"
import { t } from "~~/test/unit/test-utils/i18n"

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

Expand Down Expand Up @@ -56,6 +59,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 },
})
Expand All @@ -77,6 +81,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 },
})
Expand All @@ -101,6 +106,7 @@ for (const searchType of supportedSearchTypes) {
searchType,
})

await expect(getH1(page, t("404.title"))).toBeVisible()
await expectSnapshot(page, "generic-error", page, {
dir,
screenshotOptions: {
Expand Down Expand Up @@ -136,6 +142,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -11,6 +12,7 @@ import {
getHomepageSearchButton,
getLanguageSelect,
getLoadMoreButton,
getMenuButton,
} from "~~/test/playwright/utils/components"

test.describe.configure({ mode: "parallel" })
Expand All @@ -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"
)
Expand Down

0 comments on commit 4401e95

Please sign in to comment.