Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Storybook test changes to prevent flakiness from `sleep` (#4272)
Olga Bulat30b6f11e67f4
diff --git a/frontend/test/storybook/utils/args.ts b/frontend/test/storybook/utils/args.tsindex 9f73132f4..66147fcf7 100644--- a/frontend/test/storybook/utils/args.ts+++ b/frontend/test/storybook/utils/args.ts@@ -1,12 +1,36 @@+import type { LanguageDirection } from "~~/test/playwright/utils/i18n"+import type { Page } from "@playwright/test"-export const makeGotoWithArgs =- (storySlug: string) => (page: Page, args?: Record<string, unknown>) => {- const argStrings = Object.entries(args ?? {})- .map(([k, v]) => `${k}:${v}`)- .join(";")- const argsParam = args ? `&args=${argStrings}` : ""+export const dirParam = (dir: LanguageDirection) => {+ return dir === "ltr" ? "" : "&globals=languageDirection:rtl"+}++const buildUrl = (+ storySlug: string,+ args?: Record<string, unknown>,+ dir: LanguageDirection = "ltr"+) => {+ const argStrings = Object.entries(args ?? {})+ .map(([k, v]) => `${k}:${v}`)+ .join(";")+ const argsParam = args ? `&args=${argStrings}` : ""+ return `/iframe.html?id=${storySlug}${argsParam}${dirParam(dir)}`+}- const url = `/iframe.html?id=${storySlug}${argsParam}`+export const makeUrlWithArgs =+ (storySlug: string) =>+ (args?: Record<string, unknown>, dir: LanguageDirection = "ltr") => {+ return buildUrl(storySlug, args, dir)+ }++export const makeGotoWithArgs =+ (storySlug: string) =>+ (+ page: Page,+ args?: Record<string, unknown>,+ dir: LanguageDirection = "ltr"+ ) => {+ const url = buildUrl(storySlug, args, dir)return page.goto(url)}diff --git a/frontend/test/storybook/utils/response.ts b/frontend/test/storybook/utils/response.tsnew file mode 100644index 000000000..29fb0ada7--- /dev/null+++ b/frontend/test/storybook/utils/response.ts@@ -0,0 +1,18 @@+import { type Page } from "@playwright/test"++/**+ * Wait for a response to a URL that matches a regex.+ * The pattern of setting up a wait for response without `await`,+ * and awaiting the response after navigating to the URL is used+ * to prevent race conditions.+ * @see https://playwright.dev/docs/api/class-page#page-wait-for-request.+ */+export const waitForResponse = async (+ page: Page,+ url: string,+ responseRegex: RegExp+) => {+ const response = page.waitForResponse(responseRegex)+ await page.goto(url)+ await response+}diff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-hovered-linux.pngdeleted file mode 100644index 21eb22f82..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-linux.pngdeleted file mode 100644index d18e4dc86..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-focused-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-hovered-linux.pngdeleted file mode 100644index fd0a4e5bd..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-hovered-linux.pngdeleted file mode 100644index 8864d42ee..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-linux.pngdeleted file mode 100644index 8864d42ee..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-pressed-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-resting-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-resting-linux.pngdeleted file mode 100644index 4596bb3b1..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/dropdown-label-resting-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-hovered-linux.pngdeleted file mode 100644index a3c34131a..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-linux.pngdeleted file mode 100644index aea1d2bf1..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-focused-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-hovered-linux.pngdeleted file mode 100644index c41366e55..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-resting-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-resting-linux.pngdeleted file mode 100644index 756e0a061..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/filled-transparent-resting-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-hovered-linux.pngdeleted file mode 100644index 7128032a1..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-hovered-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-linux.pngdeleted file mode 100644index 7128032a1..000000000Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-pressed-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts b/frontend/test/storybook/visual-regression/v-filter-tab.spec.tsindex 364d8cfa7..32bd283c8 100644--- a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts+++ b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts@@ -1,39 +1,64 @@-import { expect, Page, test } from "@playwright/test"+import { expect, type Page, test } from "@playwright/test"-import { makeGotoWithArgs } from "~~/test/storybook/utils/args"+import { makeUrlWithArgs } from "~~/test/storybook/utils/args"+import { waitForResponse } from "~~/test/storybook/utils/response"-const gotoWithArgs = makeGotoWithArgs(+const urlWithArgs = makeUrlWithArgs("components-vheader-vheadermobile-vfiltertab--default-story")test.describe.configure({ mode: "parallel" })const wrapper = "[role='tablist']"+const filtersTab = "#tab-filters"++const getFiltersTab = async (page: Page) => page.locator(filtersTab)const focusFiltersTab = async (page: Page) => {- await page.keyboard.press("Tab")+ const tab = await getFiltersTab(page)+ await expect(tab).toBeVisible()+ await tab.focus()}const hoverFiltersTab = async (page: Page) => {- await page.locator("#tab-filters").hover()+ await (await getFiltersTab(page)).hover()}++/**+ * Fonts are the last request done by the storybook iframe. This function+ * allows us to wait for the story to be fully-loaded before taking a screenshot.+ */+const goAndWaitForSvg = async (+ page: Page,+ args: Record<string, string | number | boolean>+) => {+ const url = urlWithArgs(args)+ if (args.appliedFilterCount === 0) {+ await waitForResponse(page, url, /\.svg/)+ await expect(page.locator(`${filtersTab} svg`)).toBeVisible()+ } else {+ await page.goto(url)+ }+}+test.describe("VFilterTab", () => {for (const appliedFilterCount of [0, 1, 12]) {/*** If the tab is focused, it will always be selected (it's not manually activated)*/- test(`focused,${appliedFilterCount} filters`, async ({ page }) => {- await gotoWithArgs(page, { appliedFilterCount, isSelected: true })+ test(`focused, ${appliedFilterCount} filters`, async ({ page }) => {+ await goAndWaitForSvg(page, { appliedFilterCount, isSelected: true })await focusFiltersTab(page)expect(await page.locator(wrapper).screenshot()).toMatchSnapshot(`filter-tab-focused-${appliedFilterCount}.png`)})+test(`focused, hovered, ${appliedFilterCount} filters`, async ({page,}) => {- await gotoWithArgs(page, { appliedFilterCount })+ await goAndWaitForSvg(page, { appliedFilterCount })await focusFiltersTab(page)await hoverFiltersTab(page)@@ -41,21 +66,25 @@ test.describe("VFilterTab", () => {`filter-tab-focused-hovered-${appliedFilterCount}.png`)})+for (const isSelected of [true, false]) {const selected = `${isSelected ? "" : "not_"}selected`test(`resting, ${selected}, ${appliedFilterCount} filters`, async ({page,}) => {- await gotoWithArgs(page, { appliedFilterCount, isSelected })+ await goAndWaitForSvg(page, { appliedFilterCount, isSelected })+expect(await page.locator(wrapper).screenshot()).toMatchSnapshot(`filter-tab-resting-${selected}-${appliedFilterCount}.png`)})+test(`hovered, ${selected}, ${appliedFilterCount} filters`, async ({page,}) => {- await gotoWithArgs(page, { appliedFilterCount, isSelected })+ await goAndWaitForSvg(page, { appliedFilterCount, isSelected })await hoverFiltersTab(page)+expect(await page.locator(wrapper).screenshot()).toMatchSnapshot(`filter-tab-hovered-${selected}-${appliedFilterCount}.png`)diff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-not-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-not-selected-linux.pngdeleted file mode 100644index 8bd7a1b60..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-not-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-selected-linux.pngdeleted file mode 100644index 7b9f95d51..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-12-checked-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-0-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-0-linux.pngindex b2756b083..b144994a5 100644Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-0-linux.png and b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-0-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-1-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-1-linux.pngindex e50f42859..4aea2cab5 100644Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-1-linux.png and b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-1-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-not-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-not-selected-linux.pngdeleted file mode 100644index 1367b2af3..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-not-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-selected-linux.pngdeleted file mode 100644index 1367b2af3..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-checked-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-linux.pngindex ce6772e0e..5ae4ad8fa 100644Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-linux.png and b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-focused-hovered-12-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-not-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-not-selected-linux.pngdeleted file mode 100644index 69d73a91e..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-not-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-selected-linux.pngdeleted file mode 100644index 2a8343a46..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-hovered-12-checked-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-not-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-not-selected-linux.pngdeleted file mode 100644index 36742220d..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-not-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-selected-linux.png b/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-selected-linux.pngdeleted file mode 100644index 6532a2800..000000000Binary files a/frontend/test/storybook/visual-regression/v-filter-tab.spec.ts-snapshots/filter-tab-resting-12-checked-selected-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-footer.spec.ts b/frontend/test/storybook/visual-regression/v-footer.spec.tsindex d57e4077c..e904c7efc 100644--- a/frontend/test/storybook/visual-regression/v-footer.spec.ts+++ b/frontend/test/storybook/visual-regression/v-footer.spec.ts@@ -1,19 +1,42 @@-import { test } from "@playwright/test"+import { expect, Page, test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"-import { languageDirections } from "~~/test/playwright/utils/i18n"+import {+ type LanguageDirection,+ languageDirections,+ t,+} from "~~/test/playwright/utils/i18n"-const footerKinds = ["internal", "content"] as const+import { dirParam } from "~~/test/storybook/utils/args"-const defaultUrl = "/iframe.html?id=components-vfooter--"+const footerKinds = ["internal", "content"] as const-const pageUrl = (- dir: (typeof languageDirections)[number],+const storyUrl = (+ footerKind: (typeof footerKinds)[number],+ dir: LanguageDirection+) => `/iframe.html?id=components-vfooter--${footerKind}${dirParam(dir)}`++/**+ * Changes the language using the language select, and checks for elements to+ * be visible to ensure that the page is fully-loaded.+ */+const setLanguageDirection = async (+ page: Page,+ dir: LanguageDirection,footerKind: (typeof footerKinds)[number]) => {- const url = `${defaultUrl}${footerKind}`- return dir === "ltr" ? url : `${url}&globals=languageDirection:rtl`+ if (dir !== "rtl") {+ return+ }+ await page.locator("#language").selectOption({ value: "ar" })+ if (footerKind === "internal") {+ // The WP svg inside a link. The text with a placeholder is flaky in RTL.+ await expect(page.locator("a svg")).toBeVisible()+ } else {+ const aboutLink = page.getByText(t("navigation.about", "rtl"))+ await expect(aboutLink).toBeVisible()+ }}test.describe.configure({ mode: "parallel" })@@ -22,14 +45,11 @@ test.describe("VFooter", () => {for (const dir of languageDirections) {for (const footerKind of footerKinds) {breakpoints.describeEvery(({ expectSnapshot }) => {- test.beforeEach(async ({ page }) => {- await page.goto(pageUrl(dir, footerKind))- if (dir === "rtl") {- await page.locator("#language").selectOption({ value: "ar" })- }- })-test(`footer-${footerKind}-${dir}`, async ({ page }) => {+ await page.goto(storyUrl(footerKind, dir))++ await setLanguageDirection(page, dir, footerKind)+await expectSnapshot(`footer-${footerKind}-${dir}`,page.locator("footer")diff --git a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-md-linux.png b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-md-linux.pngindex 0beca9968..9146c4373 100644Binary files a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-md-linux.png and b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-md-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-sm-linux.png b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-sm-linux.pngindex fc7ef1823..122dfb541 100644Binary files a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-sm-linux.png and b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-sm-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-xs-linux.png b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-xs-linux.pngindex e5b6dada5..da9c52d39 100644Binary files a/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-xs-linux.png and b/frontend/test/storybook/visual-regression/v-footer.spec.ts-snapshots/footer-content-rtl-xs-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts b/frontend/test/storybook/visual-regression/v-header-internal.spec.tsindex 8803c8fd2..e9e5dfdc1 100644--- a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts+++ b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts@@ -1,51 +1,69 @@-import { test } from "@playwright/test"+import { expect, test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"-import { languageDirections } from "~~/test/playwright/utils/i18n"+import {+ type LanguageDirection,+ languageDirections,+ t,+} from "~~/test/playwright/utils/i18n"+import { dirParam } from "~~/test/storybook/utils/args"const headerSelector = ".main-header"const defaultUrl ="/iframe.html?id=components-vheader-vheaderinternal--default-story"-const pageUrl = (dir: (typeof languageDirections)[number]) =>- dir === "ltr" ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`+const pageUrl = (dir: LanguageDirection) => `${defaultUrl}${dirParam(dir)}`test.describe.configure({ mode: "parallel" })test.describe("VHeaderInternal", () => {for (const dir of languageDirections) {- breakpoints.describeEachDesktop(({ expectSnapshot }) => {- test(`desktop-header-internal-${dir}`, async ({ page }) => {- await page.goto(pageUrl(dir))- await page.mouse.move(0, 150)- await expectSnapshot(- `desktop-header-internal-${dir}`,- page.locator(headerSelector)- )+ test.describe(`${dir}`, () => {+ breakpoints.describeEachDesktop(({ expectSnapshot }) => {+ test(`desktop header`, async ({ page }) => {+ await page.goto(pageUrl(dir))+ await page.mouse.move(0, 150)+ await expectSnapshot(+ `desktop-header-internal-${dir}`,+ page.locator(headerSelector)+ )+ })})- })- breakpoints.describeEachMobile(({ expectSnapshot }) => {- test(`mobile-header-internal-${dir}`, async ({ page }) => {- await page.goto(pageUrl(dir))- await page.mouse.move(0, 150)- await expectSnapshot(- `mobile-header-internal-closed-${dir}`,- page.locator(headerSelector)- )++ breakpoints.describeXs(({ breakpoint }) => {+ test(`mobile header closed`, async ({ page }) => {+ await page.goto(pageUrl(dir))++ // Ensure fonts are loaded before taking the snapshot+ const responsePromise = page.waitForResponse(/var\.woff2/)+ await page.locator('button[aria-haspopup="dialog"]').click()+ await responsePromise++ await page+ .getByRole("button", { name: t("modal.closePagesMenu") })+ .click()++ await page.mouse.move(0, 150)++ await expect(page.locator(headerSelector)).toHaveScreenshot(+ `mobile-header-internal-closed-${dir}-${breakpoint}.png`+ )+ })})- 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)-- await expectSnapshot(`mobile-header-internal-open-${dir}`, page)++ breakpoints.describeEachMobile(({ expectSnapshot }) => {+ test(`mobil header with open modal`, async ({ page }) => {+ await page.goto(pageUrl(dir))++ // Ensure fonts are loaded before taking the snapshot+ const responsePromise = page.waitForResponse(/var\.woff2/)+ await page.locator('button[aria-haspopup="dialog"]').click()+ await responsePromise+ // Mouse stays over the button, so the close button is hovered.+ // To prevent this, move the mouse away.+ await page.mouse.move(0, 0)++ await expectSnapshot(`mobile-header-internal-open-${dir}`, page)+ })})})}diff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-md-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-md-linux.pngindex 2d1bf64aa..840aa7770 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-md-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-md-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-sm-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-sm-linux.pngindex 3425ea742..7eff26022 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-sm-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-ltr-sm-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-md-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-md-linux.pngindex b0104ef42..d85155d9b 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-md-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-md-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-sm-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-sm-linux.pngindex f67544b52..5dc976a11 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-sm-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-sm-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-xs-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-xs-linux.pngindex d1c05a40d..9312836ff 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-xs-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-closed-rtl-xs-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-md-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-md-linux.pngindex f938e9edf..f8c7a0f32 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-md-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-md-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-sm-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-sm-linux.pngindex f7a357898..c8dff112a 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-sm-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-sm-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-xs-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-xs-linux.pngindex bafe5caa6..d5def5646 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-xs-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-ltr-xs-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-md-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-md-linux.pngindex 9a491013b..b60a89491 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-md-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-md-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-sm-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-sm-linux.pngindex bb72bd190..1e11c5c0b 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-sm-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-sm-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-xs-linux.png b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-xs-linux.pngindex 965fb7611..a95169fe6 100644Binary files a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-xs-linux.png and b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-open-rtl-xs-linux.png differdiff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts b/frontend/test/storybook/visual-regression/v-image-cell.spec.tsindex 9dbf6c8db..f2cd560da 100644--- a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts+++ b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts@@ -1,32 +1,43 @@-import { expect, test } from "@playwright/test"--import { makeGotoWithArgs } from "~~/test/storybook/utils/args"+import { expect, type Page, test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"+import { makeUrlWithArgs } from "~~/test/storybook/utils/args"import { sleep } from "~~/test/playwright/utils/navigation"+import { waitForResponse } from "~~/test/storybook/utils/response"import type { AspectRatio } from "~/types/media"const imageCell = "a[itemprop='contentUrl']"+const imageCellImage = `${imageCell} img`// Necessary to make sure we can capture the focus state, which// exceeds the bounds of the actual componentconst screenshotEl = ".sb-main-padded"+const urlWithArgs = makeUrlWithArgs("components-vimagecell--v-image-cell")++const goAndWaitForImage = async (+ page: Page,+ args: Record<string, string | number | boolean>+) => {+ // Block the flickr direct url request so that the image cell immediately+ // falls back to the local image.+ await page.route("**flickr**", (route) => route.abort())+ await waitForResponse(page, urlWithArgs(args), /\.jpg/)+ await expect(page.locator(imageCellImage)).toBeVisible()+ await sleep(500)+}+test.describe.configure({ mode: "parallel" })test.describe("VImageCell", () => {breakpoints.describeMobileXsAndDesktop(({ expectSnapshot }) => {- const gotoWithArgs = makeGotoWithArgs("components-vimagecell--v-image-cell")const aspectRatios: AspectRatio[] = ["square", "intrinsic"]for (const ratio of aspectRatios) {test(`${ratio} loaded`, async ({ page }) => {- await gotoWithArgs(page, { aspectRatio: ratio })+ await goAndWaitForImage(page, { aspectRatio: ratio })- await sleep(500)- const mainEl = page.locator(imageCell)- await expect(mainEl).toBeVisible()await expectSnapshot(`v-image-cell-${ratio}-loaded`,page.locator(screenshotEl)@@ -34,11 +45,10 @@ test.describe("VImageCell", () => {})test(`${ratio} focused`, async ({ page }) => {- await gotoWithArgs(page, { aspectRatio: ratio })- await sleep(500)+ await goAndWaitForImage(page, { aspectRatio: ratio })await page.focus(imageCell)- await page.locator(imageCell).click()+await expectSnapshot(`v-image-cell-${ratio}-focused`,page.locator(screenshotEl)@@ -46,10 +56,10 @@ test.describe("VImageCell", () => {})test(`${ratio} hovered`, async ({ page }) => {- await gotoWithArgs(page, { aspectRatio: ratio })- await sleep(500)+ await goAndWaitForImage(page, { aspectRatio: ratio })await page.hover(imageCell)+await expectSnapshot(`v-image-cell-${ratio}-hovered`,page.locator(screenshotEl)@@ -57,12 +67,12 @@ test.describe("VImageCell", () => {})test(`${ratio} focused hovered`, async ({ page }) => {- await gotoWithArgs(page, { aspectRatio: ratio })- await sleep(500)+ await goAndWaitForImage(page, { aspectRatio: ratio })await page.focus(imageCell)await page.hover(imageCell)await page.locator(imageCell).click()+await expectSnapshot(`v-image-cell-${ratio}-focused-hovered`,page.locator(screenshotEl)diff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts b/frontend/test/storybook/visual-regression/v-search-type-button.spec.tsindex 888dd5d53..adef4c36f 100644--- a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts+++ b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts@@ -1,55 +1,53 @@-import { test } from "@playwright/test"+import { expect, type Page, test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"+import { makeUrlWithArgs } from "~~/test/storybook/utils/args"+import { waitForResponse } from "~~/test/storybook/utils/response"-const defaultUrl = (showLabel: boolean) =>- `/iframe.html?id=components-vcontentswitcher-vsearchtypebutton--default-story&args=showLabel:${showLabel}`-const pressedUrl = (showLabel: boolean) =>- `${defaultUrl(showLabel)};pressed:true`+const urlWithArgs = makeUrlWithArgs(+ "components-vcontentswitcher-vsearchtypebutton--default-story"+)const searchTypeButtonLocator = 'button[aria-haspopup="dialog"]'+const getIcon = (page: Page) =>+ page.locator(`${searchTypeButtonLocator} svg`).first()test.describe.configure({ mode: "parallel" })+const goAndWaitForSvg = async (page: Page, url: string) => {+ await waitForResponse(page, url, /\.svg/)+ await expect(getIcon(page)).toBeVisible()+}+const buttonKinds = ["icon", "withTextLabel"] as const+test.describe("VSearchTypeButton", () => {for (const buttonKind of buttonKinds) {const showLabel = buttonKind === "withTextLabel"const buttonName = `button-${showLabel ? "with" : "without"}-text-label`- breakpoints.describeMd(({ expectSnapshot }) => {- test(`resting ${buttonName}`, async ({ page }) => {- await page.goto(defaultUrl(showLabel))- await expectSnapshot(- `v-search-type-button-${buttonName}-at-rest`,- page.locator(searchTypeButtonLocator)- )- })-- test(`hovered ${buttonName}`, async ({ page }) => {- await page.goto(defaultUrl(showLabel))- await page.hover(searchTypeButtonLocator)- await expectSnapshot(- `v-search-type-button-${buttonName}-hovered `,- page.locator(searchTypeButtonLocator)- )- })-- test(`pressed ${buttonName}`, async ({ page }) => {- await page.goto(pressedUrl(showLabel))- await expectSnapshot(- `v-search-type-button-${buttonName}-pressed`,- page.locator(searchTypeButtonLocator)- )- })- test(`pressed hovered ${buttonName}`, async ({ page }) => {- await page.goto(pressedUrl(showLabel))- await page.hover(searchTypeButtonLocator)- await expectSnapshot(- `v-search-type-button-${buttonName}-pressed-hovered `,- page.locator(searchTypeButtonLocator)- )+ for (const state of ["non-pressed", "pressed"] as const) {+ const snapshotName = `v-search-type-button-${buttonName}${state === "pressed" ? "-pressed" : ""}`+ breakpoints.describeMd(({ breakpoint }) => {+ test(`resting ${state} ${buttonName}`, async ({ page }) => {+ const url = urlWithArgs({ showLabel, pressed: state === "pressed" })+ await goAndWaitForSvg(page, url)++ await expect(page.locator(searchTypeButtonLocator)).toHaveScreenshot(+ `${snapshotName}-at-rest-${breakpoint}.png`+ )+ })++ test(`hovered ${state} ${buttonName}`, async ({ page }) => {+ const url = urlWithArgs({ showLabel, pressed: state === "pressed" })+ await goAndWaitForSvg(page, url)+ await page.hover(searchTypeButtonLocator)++ await expect(page.locator(searchTypeButtonLocator)).toHaveScreenshot(+ `${snapshotName}-hovered-${breakpoint}.png`+ )+ })})- })+ }}})diff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-at-rest-lg-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-at-rest-lg-linux.pngdeleted file mode 100644index 3744946ef..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-at-rest-lg-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-hovered--md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-hovered-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-hovered--md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-hovered-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-at-rest-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-at-rest-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-hovered--md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-hovered-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-hovered--md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-with-text-label-pressed-hovered-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-hovered--md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-hovered-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-hovered--md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-hovered-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-at-rest-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-at-rest-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-hovered--md-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-hovered-md-linux.pngsimilarity index 100%rename from frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-hovered--md-linux.pngrename to frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-button-without-text-label-pressed-hovered-md-linux.pngdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-hovered-lg-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-hovered-lg-linux.pngdeleted file mode 100644index b16f02d23..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-hovered-lg-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-hovered-lg-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-hovered-lg-linux.pngdeleted file mode 100644index 3a672f518..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-hovered-lg-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-lg-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-lg-linux.pngdeleted file mode 100644index 4e7979f03..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-pressed-lg-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-at-rest-xl-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-at-rest-xl-linux.pngdeleted file mode 100644index 4e6615335..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-at-rest-xl-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-hovered-xl-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-hovered-xl-linux.pngdeleted file mode 100644index 1ceb9c78a..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-hovered-xl-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-hovered-xl-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-hovered-xl-linux.pngdeleted file mode 100644index 7d6ddcd65..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-hovered-xl-linux.png and /dev/null differdiff --git a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-xl-linux.png b/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-xl-linux.pngdeleted file mode 100644index 7ce33e248..000000000Binary files a/frontend/test/storybook/visual-regression/v-search-type-button.spec.ts-snapshots/v-search-type-button-with-text-pressed-xl-linux.png and /dev/null differ