Skip to content

Commit

Permalink
Add the correct RTL snapshots for collection headers
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Sep 16, 2024
1 parent 35e43b8 commit bf04a21
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 29 deletions.
31 changes: 10 additions & 21 deletions frontend/test/playwright/utils/breakpoints.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { test, Expect, Page, Locator } from "@playwright/test"
import { test } from "@playwright/test"

import type { LanguageDirection } from "~~/test/playwright/utils/i18n"

import { expectSnapshot as innerExpectSnapshot } from "~~/test/playwright/utils/expect-snapshot"
import {
type ExpectSnapshot,
expectSnapshot as innerExpectSnapshot,
} from "~~/test/playwright/utils/expect-snapshot"

import { VIEWPORTS } from "~/constants/screens"
import type { Breakpoint } from "~/constants/screens"

type ScreenshotAble = Page | Locator

type ExpectSnapshot = <T extends ScreenshotAble>(
page: Page,
name: string,
s: T,
config?: {
dir?: LanguageDirection
options?: Parameters<T["screenshot"]>[0]
snapshotOptions?: Parameters<ReturnType<Expect>["toMatchSnapshot"]>[0]
useColorMode?: boolean
}
) => Promise<Buffer | void>

type BreakpointBlock = (options: {
breakpoint: Breakpoint
expectSnapshot: ExpectSnapshot
Expand Down Expand Up @@ -95,11 +84,11 @@ const makeBreakpointDescribe =
return `${name}${dirString}-${breakpoint}` as const
}

const expectSnapshot = async <T extends ScreenshotAble>(
page: Page,
name: string,
screenshotAble: T,
options: Parameters<ExpectSnapshot>[3] = {}
const expectSnapshot: ExpectSnapshot = async (
page,
name,
screenshotAble,
options = {}
) => {
const snapshotName = getSnapshotName(name, options.dir)
return innerExpectSnapshot(page, snapshotName, screenshotAble, options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ breakpoints.describeXl(({ breakpoint, expectSnapshot }) => {
// eslint-disable-next-line playwright/no-networkidle
await page.waitForLoadState("networkidle")
await expectSnapshot(page, "generic-error-ltr", page, {
options: { fullPage: true },
screenshotOptions: { fullPage: true },
})
})
}
Expand All @@ -60,7 +60,7 @@ breakpoints.describeXl(({ breakpoint, expectSnapshot }) => {
await page.waitForLoadState("networkidle")

await expectSnapshot(page, "generic-error-ltr", page, {
options: { fullPage: true },
screenshotOptions: { fullPage: true },
})
})
}
Expand All @@ -81,7 +81,7 @@ for (const searchType of supportedSearchTypes) {
await goToSearchTerm(page, `SearchPage500error`, { searchType })

await expectSnapshot(page, "generic-error-ltr", page, {
options: { fullPage: true },
screenshotOptions: { fullPage: true },
})
})
})
Expand All @@ -106,7 +106,7 @@ for (const searchType of supportedSearchTypes) {

await expectSnapshot(page, "generic-error", page, {
dir,
options: {
screenshotOptions: {
fullPage: true,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ for (const mediaType of supportedMediaTypes) {
page,
{
dir,
options: { fullPage: true },
screenshotOptions: { fullPage: true },
snapshotOptions: { maxDiffPixelRatio: 0.01 },
}
)
Expand All @@ -70,7 +70,7 @@ for (const dir of languageDirections) {
await sleep(500)
await expectSnapshot(page, "full-page-report", page, {
dir,
options: { fullPage: true },
screenshotOptions: { fullPage: true },
snapshotOptions: { maxDiffPixelRatio: undefined, maxDiffPixels: 2 },
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ for (const contentPage of contentPages) {
await page.mouse.move(150, 150)
await expectSnapshot(page, contentPage, page, {
dir,
options: { fullPage: true },
snapshotOptions: { maxDiffPixelRatio: 0.005 },
screenshotOptions: { fullPage: true },
snapshotOptions: { maxDiffPixelRatio: 0.01 },
})
})
})
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bf04a21

Please sign in to comment.