Skip to content

Commit

Permalink
Await fonts loading for header
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <obulat@gmail.com>
  • Loading branch information
obulat committed Feb 6, 2024
1 parent 0e53879 commit 2c57616
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test } from "@playwright/test"

import breakpoints from "~~/test/playwright/utils/breakpoints"
import { sleep } from "~~/test/playwright/utils/navigation"
import { languageDirections } from "~~/test/playwright/utils/i18n"

const headerSelector = ".main-header"
Expand Down Expand Up @@ -35,12 +34,17 @@ test.describe("VHeaderInternal", () => {
})
test(`mobile-header-internal-modal-${dir}`, async ({ page }) => {
await page.goto(pageUrl(dir))

// Ensure fonts are loaded before taking the snapshot.
const requestPromise = page.waitForRequest((req) =>
req.url().includes("var.woff2")
)
await page.locator('button[aria-haspopup="dialog"]').click()
await requestPromise
// Mouse stays over the button, so the close button is hovered.
// To prevent this, move the mouse away.
await page.mouse.move(0, 0)
// Wait for the fonts to load.
await sleep(500)

await expectSnapshot(`mobile-header-internal-open-${dir}`, page)
})
})
Expand Down

0 comments on commit 2c57616

Please sign in to comment.