forked from SmartDropLabs/smartdrop-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrast-audit.spec.ts
More file actions
37 lines (30 loc) · 1.05 KB
/
Copy pathcontrast-audit.spec.ts
File metadata and controls
37 lines (30 loc) · 1.05 KB
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
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
const routes = ["/", "/farm", "/leaderboard"];
for (const route of routes) {
test.describe(`Colour contrast – ${route}`, () => {
test("dark mode passes WCAG 2.1 AA", async ({ page }) => {
await page.goto(route);
// Ensure dark mode is active via localStorage
await page.evaluate(() =>
localStorage.setItem("chakra-ui-color-mode", "dark")
);
await page.reload();
const results = await new AxeBuilder({ page })
.withRules(["color-contrast"])
.analyze();
expect(results.violations).toEqual([]);
});
test("light mode passes WCAG 2.1 AA", async ({ page }) => {
await page.goto(route);
await page.evaluate(() =>
localStorage.setItem("chakra-ui-color-mode", "light")
);
await page.reload();
const results = await new AxeBuilder({ page })
.withRules(["color-contrast"])
.analyze();
expect(results.violations).toEqual([]);
});
});
}