-
Notifications
You must be signed in to change notification settings - Fork 202
/
pages-single-result.spec.ts
81 lines (69 loc) · 2.43 KB
/
pages-single-result.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { test } from "@playwright/test"
import breakpoints from "~~/test/playwright/utils/breakpoints"
import {
goToSearchTerm,
openFirstResult,
pathWithDir,
preparePageForTests,
sleep,
} from "~~/test/playwright/utils/navigation"
import { languageDirections } from "~~/test/playwright/utils/i18n"
import { supportedMediaTypes } from "~/constants/media"
test.describe.configure({ mode: "parallel" })
for (const isOn of [true, false]) {
for (const mediaType of supportedMediaTypes) {
for (const dir of languageDirections) {
breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
test(`${mediaType} ${dir} single-result page snapshots from search results, additional search views: ${isOn}`, async ({
page,
}) => {
await preparePageForTests(page, breakpoint, {
features: { additional_search_views: isOn ? "on" : "off" },
})
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" })
// This will include the "Back to results" link.
await openFirstResult(page, mediaType, dir)
await expectSnapshot(
`${mediaType}-${dir}-from-search-results${
isOn ? "-with-additional-search-views" : ""
}`,
page,
{ fullPage: true },
{ maxDiffPixelRatio: 0.01 }
)
})
})
}
}
}
for (const dir of languageDirections) {
breakpoints.describeMobileAndDesktop(({ breakpoint, expectSnapshot }) => {
test(`${dir} full-page report snapshots`, async ({ page }) => {
await preparePageForTests(page, breakpoint)
const IMAGE_ID = "da5cb478-c093-4d62-b721-cda18797e3fb"
const path = pathWithDir(`/image/${IMAGE_ID}/report`, dir)
await page.goto(path)
// Wait for the language select to hydrate.
await sleep(500)
await expectSnapshot(
`${dir}-full-page-report`,
page,
{ fullPage: true },
{ maxDiffPixelRatio: undefined, maxDiffPixels: 2 }
)
})
})
}