This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
homepage.spec.ts
79 lines (67 loc) · 2.28 KB
/
homepage.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
import { test, Page } from "@playwright/test"
import breakpoints from "~~/test/playwright/utils/breakpoints"
import { hideInputCursors } from "~~/test/playwright/utils/page"
import {
dismissTranslationBanner,
pathWithDir,
languageDirections,
} from "~~/test/playwright/utils/navigation"
test.describe.configure({ mode: "parallel" })
/**
* Make the random set of images uniform by dropping their brightness to zero,
* and changing them into black circles.
*/
const cleanImageCarousel = async (page: Page) => {
await page.addStyleTag({
content: ".home-cell > img { filter: brightness(0%); }",
})
await page.waitForTimeout(1000) // wait for animation to finish
}
for (const dir of languageDirections) {
test.describe(`${dir} homepage snapshots`, () => {
const path = pathWithDir("/", dir)
test.beforeEach(async ({ page }) => {
await page.goto(path)
await dismissTranslationBanner(page)
await cleanImageCarousel(page)
})
breakpoints.describeEvery(({ expectSnapshot }) =>
test(`${dir} full page`, async ({ page }) => {
await expectSnapshot(`index-${dir}`, page)
})
)
test.describe("search input", () => {
breakpoints.describeEvery(({ expectSnapshot }) => {
test("unfocused", async ({ page }) => {
await expectSnapshot(
`unfocused-search-${dir}`,
page.locator("form:has(input)")
)
})
test("focused", async ({ page }) => {
await page.focus("input")
await hideInputCursors(page)
await expectSnapshot(
`focused-search-${dir}`,
page.locator("form:has(input)")
)
})
test("content switcher open", async ({ page }) => {
await page.locator("#search-type-button").click()
await expectSnapshot(`content-switcher-open-${dir}`, page)
})
test("content switcher with external sources open", async ({
page,
}) => {
await page.goto(pathWithDir("/?ff_external_sources=on", dir))
await cleanImageCarousel(page)
await page.locator("#search-type-button").click()
await expectSnapshot(
`content-switcher-with-external-sources-open-${dir}`,
page
)
})
})
})
})
}