Skip to content

Commit

Permalink
Rename all snapshots to "-light"
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Sep 13, 2024
1 parent 788369b commit c635aa1
Show file tree
Hide file tree
Showing 572 changed files with 35 additions and 45 deletions.
10 changes: 4 additions & 6 deletions frontend/test/playwright/utils/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ExpectSnapshot = <T extends ScreenshotAble>(

type BreakpointBlock = (options: {
getConfigValues: (name: string) => {
name: `${typeof name}-${Breakpoint}.png`
name: `${typeof name}-${Breakpoint}-light.png`
}
breakpoint: Breakpoint
expectSnapshot: ExpectSnapshot
Expand Down Expand Up @@ -88,7 +88,7 @@ const makeBreakpointDescribe =
})

const getConfigValues = (name: string) => ({
name: `${name}-${breakpoint}.png` as const,
name: `${name}-${breakpoint}-light.png` as const,
})

const expectSnapshot = async <T extends ScreenshotAble>(
Expand All @@ -99,10 +99,8 @@ const makeBreakpointDescribe =
) => {
const { name: snapshotName } = getConfigValues(name)
return expect(await screenshotAble.screenshot(options)).toMatchSnapshot(
{
name: snapshotName,
...snapshotOptions,
}
snapshotName,
snapshotOptions
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ for (const dir of languageDirections) {
// To make the tests consistent, set the played area to the same position
await page.mouse.click(170, 650)

await expectSnapshot(`global-audio-player-on-search-${dir}.png`, page)
await expectSnapshot(`global-audio-player-on-search-${dir}`, page)
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe.configure({ mode: "parallel" })
const headerSelector = ".main-header"

for (const dir of languageDirections) {
test.describe(`header-${dir}`, () => {
test.describe(dir, () => {
breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
test.beforeEach(async ({ page }) => {
await preparePageForTests(page, breakpoint, { dismissFilter: false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for (const mediaType of supportedMediaTypes) {
// This will include the "Back to results" link.
await openFirstResult(page, mediaType, dir)
await expectSnapshot(
`${mediaType}-${dir}-from-search-results-with-additional-search-views`,
`${mediaType}-from-search-results-with-additional-search-views-${dir}`,
page,
{ fullPage: true },
{ maxDiffPixelRatio: 0.01 }
Expand All @@ -65,7 +65,7 @@ for (const dir of languageDirections) {
// Wait for the language select to hydrate.
await sleep(500)
await expectSnapshot(
`${dir}-full-page-report`,
`full-page-report-${dir}`,
page,
{ fullPage: true },
{ maxDiffPixelRatio: undefined, maxDiffPixels: 2 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ test.describe("layout color is set correctly", () => {
await page.waitForURL(/ar\/search/)
await expect(getH1(page, "Cat")).toBeVisible()

expect(await page.screenshot()).toMatchSnapshot("search-page-rtl-lg.png")
expect(await page.screenshot()).toMatchSnapshot(
"search-page-rtl-lg-light.png"
)
})

test("change language on homepage and go to content page", async ({
Expand All @@ -97,7 +99,7 @@ test.describe("layout color is set correctly", () => {
await page.mouse.move(100, 100)

expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
"about-ltr-lg.png",
"about-ltr-lg-light.png",
{ maxDiffPixelRatio: 0.01 }
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
})

test("page with all banners", async ({ page }) => {
await expectSnapshot(`page-with-all-banners`, page)
await expectSnapshot("page-with-all-banners", page)
})
})
2 changes: 1 addition & 1 deletion frontend/test/storybook/utils/expect-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const expectSnapshot = async (
locator: Locator | Page,
options?: ExpectSnapshotOptions
) => {
const snapshotName = `${name}.png`
const snapshotName = `${name}-light.png`
return expect(
await locator.screenshot(options?.screenshotOptions)
).toMatchSnapshot(snapshotName, options?.snapshotOptions)
Expand Down
Loading

0 comments on commit c635aa1

Please sign in to comment.