Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix single result page test flakiness (#3186)
Olga Bulat7239399852bf
diff --git a/frontend/src/composables/use-layout.ts b/frontend/src/composables/use-layout.tsindex 4ce2a3d3e..19a303aac 100644--- a/frontend/src/composables/use-layout.ts+++ b/frontend/src/composables/use-layout.ts@@ -1,4 +1,4 @@-import { useWindowSize, watchThrottled } from "@vueuse/core"+import { useWindowSize, watchDebounced } from "@vueuse/core"import type { RealBreakpoint } from "~/constants/screens"import { ALL_SCREEN_SIZES } from "~/constants/screens"@@ -24,13 +24,13 @@ export function useLayout() {uiStore.updateBreakpoint(widthToBreakpoint(width.value))}- watchThrottled(+ watchDebounced(width,(newWidth) => {const newBp = widthToBreakpoint(newWidth)uiStore.updateBreakpoint(newBp)},- { throttle: 100 }+ { debounce: 100 })return {diff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.tsindex f175f6474..6c71bacaa 100644--- a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts+++ b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts@@ -1,4 +1,4 @@-import { Page, test } from "@playwright/test"+import { test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"import {@@ -13,34 +13,35 @@ import { supportedMediaTypes } from "~/constants/media"test.describe.configure({ mode: "parallel" })-const cleanRelatedImages = async (page: Page) => {- await page.addStyleTag({- content: ".image-grid img { filter: brightness(0%); }",- })- // eslint-disable-next-line playwright/no-wait-for-timeout- await page.waitForTimeout(200)-}-for (const mediaType of supportedMediaTypes) {for (const dir of languageDirections) {breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {- // https://github.com/WordPress/openverse/issues/3112- test.skip(`${mediaType} ${dir} single-result page snapshots from search results`, async ({+ test(`${mediaType} ${dir} single-result page snapshots from search results`, async ({page,}) => {await preparePageForTests(page, breakpoint)+ await page.route("**", (route) => {+ const url = route.request().url()+ // For audio, use the generated image instead of requesting the+ // thumbnail.+ if (+ url.endsWith(".jpg") ||+ (url.endsWith("/thumb/") && url.includes("/audio/"))+ ) {+ route.abort()+ } else {+ route.continue()+ }+ })++ await goToSearchTerm(page, "birds", { dir, mode: "SSR" })- await goToSearchTerm(page, "birds", { dir })// This will include the "Back to results" link.await openFirstResult(page, mediaType)- await cleanRelatedImages(page)-await expectSnapshot(`${mediaType}-${dir}-from-search-results`,page,- {- fullPage: true,- },+ { fullPage: true },{ maxDiffPixelRatio: 0.01 })})diff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-2xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-2xl-linux.pngindex be0d50840..1447bce4d 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-2xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-2xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-lg-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-lg-linux.pngindex 3b2673bca..a4790d57c 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-lg-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-lg-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-md-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-md-linux.pngindex 2af9ea269..8cbbd7d09 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-md-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-md-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-sm-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-sm-linux.pngindex 3501736e8..d9747e2cb 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-sm-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-sm-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xl-linux.pngindex 9334e0b26..c620ec857 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xs-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xs-linux.pngindex dd41c8fdc..21374892c 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xs-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-ltr-from-search-results-xs-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-2xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-2xl-linux.pngindex 9243bee47..8ef08f908 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-2xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-2xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-lg-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-lg-linux.pngindex b894db721..11d8203dc 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-lg-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-lg-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-md-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-md-linux.pngindex 9877e1900..daf50b9c0 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-md-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-md-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-sm-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-sm-linux.pngindex e27eaa56f..ca39a427b 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-sm-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-sm-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xl-linux.pngindex 267596a7c..6451d5652 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xs-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xs-linux.pngindex 3dbf0ca2e..db719cd56 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xs-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/audio-rtl-from-search-results-xs-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-2xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-2xl-linux.pngindex cbb6d36f4..dd4eed1bf 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-2xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-2xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-lg-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-lg-linux.pngindex d9f9c88a8..1c2fd23d2 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-lg-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-lg-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-md-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-md-linux.pngindex 812314cd4..2bc2a255f 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-md-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-md-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-sm-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-sm-linux.pngindex 70aec2034..960511eb9 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-sm-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-sm-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xl-linux.pngindex b07ae68ce..cb83f6b38 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xs-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xs-linux.pngindex 64672a4dd..f6df52033 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xs-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-ltr-from-search-results-xs-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-2xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-2xl-linux.pngindex cf731feff..62a4ecacb 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-2xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-2xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-lg-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-lg-linux.pngindex 9e936e6de..90218bda9 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-lg-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-lg-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-md-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-md-linux.pngindex 49d4578a1..faab26657 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-md-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-md-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-sm-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-sm-linux.pngindex 800c778a8..1ecb4ecc9 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-sm-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-sm-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xl-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xl-linux.pngindex 09eea17e1..425fcd964 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xl-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xl-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xs-linux.png b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xs-linux.pngindex 4996b89e1..1c0b5106c 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xs-linux.png and b/frontend/test/playwright/visual-regression/pages/pages-single-result.spec.ts-snapshots/image-rtl-from-search-results-xs-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/pages.spec.ts b/frontend/test/playwright/visual-regression/pages/pages.spec.tsindex a78fcad97..45a106b02 100644--- a/frontend/test/playwright/visual-regression/pages/pages.spec.ts+++ b/frontend/test/playwright/visual-regression/pages/pages.spec.ts@@ -1,4 +1,4 @@-import { expect, Page, test } from "@playwright/test"+import { expect, test } from "@playwright/test"import breakpoints from "~~/test/playwright/utils/breakpoints"import { removeHiddenOverflow } from "~~/test/playwright/utils/page"@@ -46,14 +46,6 @@ for (const contentPage of contentPages) {}}-const cleanImageResults = async (page: Page) => {- await page.addStyleTag({- content: ".results-grid img { filter: brightness(0%); }",- })- // eslint-disable-next-line playwright/no-wait-for-timeout- await page.waitForTimeout(500)-}-test.describe("Layout color is set correctly", () => {breakpoints.describeLg(() => {test.beforeEach(async ({ page }) => {@@ -63,13 +55,11 @@ test.describe("Layout color is set correctly", () => {test("Change language on homepage and search", async ({ page }) => {await page.goto("/")await page.getByRole("combobox", { name: "Language" }).selectOption("ar")-await page.getByPlaceholder("البحث عن محتوى").fill("cat")-await page.getByRole("button", { name: "يبحث" }).click()- await page.waitForURL(/ar\/search/)- await cleanImageResults(page)+ await page.waitForURL(/ar\/search/)+ await expect(page.getByRole("heading", { name: "Cat" })).toBeVisible()expect(await page.screenshot()).toMatchSnapshot("search-page-rtl-lg.png")})diff --git a/frontend/test/playwright/visual-regression/pages/pages.spec.ts-snapshots/search-page-rtl-lg-linux.png b/frontend/test/playwright/visual-regression/pages/pages.spec.ts-snapshots/search-page-rtl-lg-linux.pngindex c39e1a3dd..d045b1e8f 100644Binary files a/frontend/test/playwright/visual-regression/pages/pages.spec.ts-snapshots/search-page-rtl-lg-linux.png and b/frontend/test/playwright/visual-regression/pages/pages.spec.ts-snapshots/search-page-rtl-lg-linux.png differdiff --git a/frontend/test/playwright/visual-regression/pages/search-with-banners.spec.ts-snapshots/page-with-all-banners-2xl-linux.png b/frontend/test/playwright/visual-regression/pages/search-with-banners.spec.ts-snapshots/page-with-all-banners-2xl-linux.pngindex 277213649..473f44db6 100644Binary files a/frontend/test/playwright/visual-regression/pages/search-with-banners.spec.ts-snapshots/page-with-all-banners-2xl-linux.png and b/frontend/test/playwright/visual-regression/pages/search-with-banners.spec.ts-snapshots/page-with-all-banners-2xl-linux.png differ