d8aac21e2d
Adds @axe-core/playwright with a shared fixture providing an `axe` helper. New a11y.spec.ts runs WCAG 2.1 AA checks on signin, dashboard, timeline, allocations, resources, and projects pages. Currently reports violations as warnings — upgrade to hard failures after fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
826 B
TypeScript
25 lines
826 B
TypeScript
import { test as base, expect } from "@playwright/test";
|
|
import AxeBuilder from "@axe-core/playwright";
|
|
|
|
/**
|
|
* Shared Playwright fixture that adds an `axe` helper to every test.
|
|
* Usage:
|
|
* import { test, expect } from "./a11y-fixture.js";
|
|
* test("page is accessible", async ({ axe }) => {
|
|
* const results = await axe.analyze();
|
|
* expect(results.violations).toEqual([]);
|
|
* });
|
|
*/
|
|
export const test = base.extend<{ axe: AxeBuilder }>({
|
|
axe: async ({ page }, use) => {
|
|
const builder = new AxeBuilder({ page })
|
|
// Exclude known third-party widgets that we cannot control
|
|
.exclude("#__next-build-indicator")
|
|
// Only check WCAG 2.1 AA — the standard most teams target
|
|
.withTags(["wcag2a", "wcag21a", "wcag2aa", "wcag21aa"]);
|
|
await use(builder);
|
|
},
|
|
});
|
|
|
|
export { expect };
|