39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import AxeBuilder from "@axe-core/playwright";
|
|
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
|
|
test("persists an explicit color scheme through the storage contract", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
const selector = page.getByRole("combobox", { name: "색상 테마" });
|
|
|
|
await selector.selectOption("dark");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
|
|
await expect(page.locator("html")).toHaveCSS("color-scheme", "dark");
|
|
const results = await new AxeBuilder({ page })
|
|
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
|
|
.analyze();
|
|
expect(
|
|
results.violations.filter((violation) =>
|
|
["critical", "serious"].includes(violation.impact ?? ""),
|
|
),
|
|
).toEqual([]);
|
|
|
|
await page.reload();
|
|
await expect(selector).toHaveValue("dark");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
|
|
});
|
|
|
|
test("tracks operating-system changes while system preference is selected", async ({
|
|
page,
|
|
}) => {
|
|
await page.emulateMedia({ colorScheme: "dark" });
|
|
await page.goto("/");
|
|
const selector = page.getByRole("combobox", { name: "색상 테마" });
|
|
await selector.selectOption("system");
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
|
|
|
|
await page.emulateMedia({ colorScheme: "light" });
|
|
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
|
|
});
|