Files
jobtrackingapp/job-tracker-ui/e2e/accessibility.spec.ts
T
2026-08-31 12:09:32 +02:00

41 lines
1.4 KiB
TypeScript

import AxeBuilder from "@axe-core/playwright";
import { expect, test, type Page } from "@playwright/test";
async function expectAccessible(page: Page, label: string) {
const results = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
.analyze();
expect(results.violations, `${label}: ${JSON.stringify(results.violations, null, 2)}`).toEqual([]);
}
async function login(page: Page) {
await page.goto("/login");
await page.getByLabel("Email").fill("e2e@example.test");
await page.getByLabel("Current password").fill("E2ePassword123!");
await page.getByRole("button", { name: "Sign in", exact: true }).click();
await expect(page).toHaveURL(/\/dashboard$/);
}
test.beforeEach(async ({ page }) => {
await page.addInitScript(() => window.localStorage.setItem("uiLanguage", "en"));
});
test("public entry points meet automated WCAG A and AA checks", async ({ page }) => {
for (const route of ["/", "/login"]) {
await page.goto(route);
await expect(page.locator("body")).toBeVisible();
await expectAccessible(page, route);
}
});
test("primary authenticated workspaces meet automated WCAG A and AA checks", async ({ page }) => {
await login(page);
for (const route of ["/dashboard", "/jobs", "/kanban", "/career", "/settings", "/admin/system"]) {
await page.goto(route);
await expect(page.locator("main")).toBeVisible();
await expectAccessible(page, route);
}
});