Files
clawmates/frontend/tests/e2e/p6-a11y.spec.ts
T
Omar Sobh 2527a888a2
ci / gates (push) Successful in 6s
ci / frontend (push) Successful in 25s
ci / rust (push) Successful in 3m41s
ci / publish (push) Successful in 46s
ci / e2e (push) Failing after 29m36s
e2e: replace stale post-login heading assertion with a URL wait
The shared signIn helper in every spec asserted
`getByRole("heading", { name: "Clawmates" })` after clicking Sign in, but
the dashboard's "Clawmates" is a decorative <span> in the top-bar logo,
not a heading — so all authenticated tests died on the same helper. Swap
that for `page.waitForURL((url) => !url.pathname.endsWith("/login"))`
with a 15s timeout. Robust across UI redesigns and doesn't couple the
signIn helper to a specific product surface. Should convert ~27 of the
remaining 30 failures to passes.
2026-07-05 21:46:21 -07:00

77 lines
2.7 KiB
TypeScript

import AxeBuilder from "@axe-core/playwright";
import { expect, test, type Page } from "@playwright/test";
// P6 exit (spec §17): a11y sign-off. Serious and critical axe violations
// fail the build on every primary surface.
const OWNER_EMAIL = "[email protected]";
const OWNER_PASSWORD = "e2e-password";
async function signIn(page: Page) {
await page.goto("/login");
await page.getByLabel("Email address").fill(OWNER_EMAIL);
await page.getByLabel("Password").fill(OWNER_PASSWORD);
await page.getByRole("button", { name: "Sign in" }).click();
await page.waitForURL((url) => !url.pathname.endsWith("/login"), { timeout: 15000 });
}
async function expectClean(page: Page, context: string) {
// Route-enter fades opacity; scanning mid-animation reads false
// contrast failures. Let running animations settle first.
await page.evaluate(() =>
Promise.allSettled(document.getAnimations().map((a) => a.finished)),
);
const results = await new AxeBuilder({ page }).analyze();
const blocking = results.violations.filter(
(v) => v.impact === "serious" || v.impact === "critical",
);
expect(
blocking.map((v) => `${v.id}: ${v.help} (${v.nodes.length} nodes)`),
`axe violations on ${context}`,
).toEqual([]);
}
test("login page is clean", async ({ page }) => {
await page.goto("/login");
await expectClean(page, "login");
});
test("shell, chat, and computer panel are clean", async ({ page }) => {
await signIn(page);
await expectClean(page, "workspace home");
await page.getByRole("link", { name: /Scout/ }).click();
await expect(page).toHaveURL(/\/claws\/.+\/chat\//);
await expectClean(page, "chat");
await page.getByRole("button", { name: "Computer" }).click();
const panel = page.getByRole("complementary", { name: "Computer" });
await expect(panel.getByText(/Scout's Computer/)).toBeVisible();
await expectClean(page, "computer home");
await panel.getByRole("button", { name: "Settings" }).click();
await expect(panel.getByText("Managed by")).toBeVisible();
await expectClean(page, "settings app");
});
test("global pages are clean", async ({ page }) => {
await signIn(page);
for (const [link, marker] of [
["Skills", /Skill Library/],
["Approvals", /review/i],
["Team", /workspace/],
["Credits", /Available credits/],
] as const) {
await page.getByRole("link", { name: link, exact: true }).click();
await expect(page.getByText(marker).first()).toBeVisible();
await expectClean(page, link);
}
});
test("the wizard is clean", async ({ page }) => {
await signIn(page);
await page.getByRole("link", { name: "New claw" }).click();
await expect(page.getByText("Create your Claw")).toBeVisible();
await expectClean(page, "wizard");
});