Skip to content

Commit

Permalink
Correctly pass maxDiffPixelRatio to add tolerance for pages-single-…
Browse files Browse the repository at this point in the history
…result VR test (#1960)

Correctly pass `maxDiffPixelRatio` to add tolerance
  • Loading branch information
obulat committed May 2, 2023
1 parent a3fa05c commit 67cca9f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 deletions.
7 changes: 0 additions & 7 deletions frontend/test/playwright/utils/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,10 @@ interface Options {
* @defaultValue true
*/
uaMocking?: boolean
/**
* Adjust the error tolerance for a single test to avoid
* flakiness.
* Do not set to a value higher than 0.02.
*/
maxDiffPixelRatio?: number
}

const defaultOptions = Object.freeze({
uaMocking: true,
maxDiffPixelRatio: 0,
})

const makeBreakpointDescribe =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,27 @@ test.describe.configure({ mode: "parallel" })
for (const mediaType of supportedMediaTypes) {
for (const dir of languageDirections) {
test.describe(`${mediaType} ${dir} single-result page snapshots`, () => {
breakpoints.describeEvery(
{ maxDiffPixelRatio: 0.02 },
({ breakpoint, expectSnapshot }) => {
test.beforeEach(async ({ page }) => {
await closeFiltersUsingCookies(page)
await dismissBannersUsingCookies(page)
await setBreakpointCookie(page, breakpoint)

await goToSearchTerm(page, "birds", { dir })
})

test(`from search results`, async ({ page }) => {
// This will include the "Back to results" link.
await openFirstResult(page, mediaType)

await expectSnapshot(
`${mediaType}-${dir}-from-search-results`,
page,
{ fullPage: true }
)
})
}
)
breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
test.beforeEach(async ({ page }) => {
await closeFiltersUsingCookies(page)
await dismissBannersUsingCookies(page)
await setBreakpointCookie(page, breakpoint)

await goToSearchTerm(page, "birds", { dir })
})

test(`from search results`, async ({ page }) => {
// This will include the "Back to results" link.
await openFirstResult(page, mediaType)

await expectSnapshot(
`${mediaType}-${dir}-from-search-results`,
page,
{ fullPage: true },
{ maxDiffPixelRatio: 0.02 }
)
})
})
})
}
}
Expand Down

0 comments on commit 67cca9f

Please sign in to comment.