test(a11y): scan the rendered route, signed in and per state (08-05, 11-02)
axe ran as soon as `main` showed, which is the app shell's loading surface, and protected routes were scanned on the sign-in prompt. The specs now wait for the route's h1, sign in first, and scan the reference list, detail, form and status states. The state-surfaces baseline was the loading surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
861383283c
commit
f17572a4be
@@ -63,3 +63,16 @@ The reviewer must verify:
|
||||
not be marked not-applicable on that route. Passing automated evidence means
|
||||
only that tested pages had no critical or serious axe findings under the
|
||||
recorded Chromium, Firefox, and WebKit runs.
|
||||
|
||||
What the automated run scans:
|
||||
|
||||
- Every registered route, after the route's own `h1` is on screen, so the scan
|
||||
never lands on the app shell's loading surface
|
||||
(`tests/e2e/accessibility.spec.ts`). A public route's `h1` must equal its
|
||||
catalog title.
|
||||
- Protected routes after the demo sign-in, never the sign-in prompt. Their API
|
||||
calls answer an empty list there.
|
||||
- The reference sample's list in its success, empty and error states, its
|
||||
detail, its form with submit errors and its status page, each after that
|
||||
state is on screen (`tests/e2e/reference-form.spec.ts`, removed with the
|
||||
sample).
|
||||
|
||||
@@ -1,23 +1,48 @@
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
||||
import { expect, test, type Page } from "../support/browser/strict-browser-test.ts";
|
||||
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.ts";
|
||||
import { KO_MESSAGES } from "../../src/presentation/i18n/catalog.ts";
|
||||
|
||||
for (const route of Object.values(ROUTE_REGISTRY).map((definition) => {
|
||||
if (definition.path === "*") return "/not-found";
|
||||
return definition.path.replace(":resourceId", "reference-1");
|
||||
})) {
|
||||
const WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"];
|
||||
const SIGN_IN_TITLE = KO_MESSAGES["route.auth.required.title"];
|
||||
const CATALOG = KO_MESSAGES as Readonly<Record<string, string>>;
|
||||
|
||||
async function blockingViolations(page: Page) {
|
||||
const results = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze();
|
||||
return results.violations.filter((violation) =>
|
||||
["critical", "serious"].includes(violation.impact ?? ""),
|
||||
);
|
||||
}
|
||||
|
||||
// 08-05/11-02. The app shell draws `main` before the route chunk arrives, so
|
||||
// axe waits for the route's own h1. A public route's h1 is its catalog title.
|
||||
// A protected route is scanned after the demo sign-in, never on the sign-in
|
||||
// prompt; the feature's own spec pins its exact headings and states.
|
||||
for (const definition of Object.values(ROUTE_REGISTRY)) {
|
||||
const route =
|
||||
definition.path === "*"
|
||||
? "/not-found"
|
||||
: definition.path.replace(":resourceId", "reference-1");
|
||||
test(`@a11y ${route} has no critical or serious axe violations`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto(route);
|
||||
await expect(page.getByRole("main")).toBeVisible();
|
||||
const results = await new AxeBuilder({ page })
|
||||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
|
||||
.analyze();
|
||||
const blocking = results.violations.filter((violation) =>
|
||||
["critical", "serious"].includes(violation.impact ?? ""),
|
||||
);
|
||||
expect(blocking).toEqual([]);
|
||||
const heading = page.getByRole("heading", { level: 1 });
|
||||
if (definition.access === "session-required") {
|
||||
// Feature data is not this spec's subject: any API answers an empty list.
|
||||
await page.route("http://localhost:8080/api/**", (request) =>
|
||||
request.fulfill({ json: [] }),
|
||||
);
|
||||
await page.goto(route);
|
||||
await expect(heading).toHaveText(SIGN_IN_TITLE);
|
||||
await page.getByRole("button", { name: "로그인 시작" }).click();
|
||||
await expect(heading).toBeVisible();
|
||||
await expect(heading).not.toHaveText(SIGN_IN_TITLE);
|
||||
} else {
|
||||
await page.goto(route);
|
||||
const title = CATALOG[`route.${definition.routeId}.title`];
|
||||
await expect(heading).toHaveText(title ?? definition.title);
|
||||
}
|
||||
expect(await blockingViolations(page)).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,7 +73,7 @@ test("@a11y opened design-system dialog has no blocking violations", async ({
|
||||
await page.getByRole("button", { name: "모달 열기" }).click();
|
||||
const results = await new AxeBuilder({ page })
|
||||
.include(".ui-dialog")
|
||||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
|
||||
.withTags(WCAG_TAGS)
|
||||
.analyze();
|
||||
expect(
|
||||
results.violations.filter((violation) =>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
||||
|
||||
@@ -78,3 +79,72 @@ test("renders the reference screens without Korean copy in en-US", async ({
|
||||
await expect(main.getByRole("button", { name: "Save" })).toBeVisible();
|
||||
await expect(main).not.toContainText(/[가-힣]/);
|
||||
});
|
||||
|
||||
const LIST_PATH = "/examples/reference-resources";
|
||||
const LIST_API = "http://localhost:8080/api/reference-resources?*";
|
||||
const BROWSER_REFERENCE = {
|
||||
id: "browser-reference",
|
||||
name: "Browser reference",
|
||||
createdAt: "2026-07-26T00:00:00.000Z",
|
||||
};
|
||||
|
||||
async function signInAt(page: Page, path: string, heading: string) {
|
||||
await page.goto(path);
|
||||
await page.getByRole("button", { name: "로그인 시작" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText(heading);
|
||||
}
|
||||
|
||||
async function expectNoBlockingViolations(page: Page) {
|
||||
const results = await new AxeBuilder({ page })
|
||||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
|
||||
.analyze();
|
||||
expect(
|
||||
results.violations.filter((violation) =>
|
||||
["critical", "serious"].includes(violation.impact ?? ""),
|
||||
),
|
||||
).toEqual([]);
|
||||
}
|
||||
|
||||
// 08-05. The protected reference screens are scanned signed in and in each
|
||||
// state they can show. The state must be on screen before axe runs.
|
||||
for (const [state, payload, visible] of [
|
||||
["success", [BROWSER_REFERENCE], "Browser reference"],
|
||||
["empty", [], "표시할 항목이 없습니다."],
|
||||
// A 200 that breaks the response schema: a 5xx would also log a console
|
||||
// error, which the strict fixture rejects on its own.
|
||||
["error", [{ wrong: true }], "서버 응답 데이터가 현재 화면과 맞지 않습니다."],
|
||||
] as const) {
|
||||
test(`@a11y reference list ${state} state has no blocking violations`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route(LIST_API, (route) => route.fulfill({ json: payload }));
|
||||
await signInAt(page, LIST_PATH, "Reference feature");
|
||||
await expect(page.getByRole("main")).toContainText(visible);
|
||||
await expectNoBlockingViolations(page);
|
||||
});
|
||||
}
|
||||
|
||||
test("@a11y reference detail has no blocking violations", async ({ page }) => {
|
||||
await page.route(
|
||||
"http://localhost:8080/api/reference-resources/browser-reference",
|
||||
(route) => route.fulfill({ json: BROWSER_REFERENCE }),
|
||||
);
|
||||
await signInAt(page, `${LIST_PATH}/browser-reference`, "Browser reference");
|
||||
await expectNoBlockingViolations(page);
|
||||
});
|
||||
|
||||
test("@a11y reference form with submit errors has no blocking violations", async ({
|
||||
page,
|
||||
}) => {
|
||||
await signInAt(page, `${LIST_PATH}/new`, "Reference resource 만들기");
|
||||
await page.getByRole("button", { name: "저장" }).click();
|
||||
await expect(page.getByRole("alert")).toContainText("입력 내용을 확인해 주세요.");
|
||||
await expectNoBlockingViolations(page);
|
||||
});
|
||||
|
||||
test("@a11y reference status page has no blocking violations", async ({
|
||||
page,
|
||||
}) => {
|
||||
await signInAt(page, `${LIST_PATH}/status`, "잠시 사용할 수 없습니다.");
|
||||
await expectNoBlockingViolations(page);
|
||||
});
|
||||
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 113 KiB |
@@ -1,12 +1,19 @@
|
||||
import {
|
||||
expect,
|
||||
test,
|
||||
type Page,
|
||||
} from "../support/browser/strict-browser-test.ts";
|
||||
|
||||
// 11-02. `main` is drawn before the route chunk arrives; a screenshot taken
|
||||
// then pins the loading surface instead of the page.
|
||||
async function expectRouteHeading(page: Page, title: string) {
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText(title);
|
||||
}
|
||||
|
||||
test("wide application shell visual contract", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("main")).toBeVisible();
|
||||
await expectRouteHeading(page, "Clean Architecture Frontend");
|
||||
await expect(page).toHaveScreenshot("app-shell-wide-light.png", {
|
||||
fullPage: true,
|
||||
});
|
||||
@@ -15,6 +22,7 @@ test("wide application shell visual contract", async ({ page }) => {
|
||||
test("compact drawer and pseudo-locale visual contract", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto("/");
|
||||
await expectRouteHeading(page, "Clean Architecture Frontend");
|
||||
await page.locator("#locale-preference").selectOption("en-XA");
|
||||
await page.locator(".app-shell__menu-button").click();
|
||||
await expect(page.locator(".ui-drawer")).toHaveJSProperty("open", true);
|
||||
@@ -26,6 +34,7 @@ test("compact drawer and pseudo-locale visual contract", async ({ page }) => {
|
||||
test("design-system gallery dark visual contract", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.goto("/examples/ui");
|
||||
await expectRouteHeading(page, "UI 구성요소");
|
||||
await page.locator("#theme-preference").selectOption("dark");
|
||||
await expect(page.getByRole("main")).toHaveScreenshot(
|
||||
"design-system-gallery-dark.png",
|
||||
@@ -37,6 +46,7 @@ test("loading empty error and access surfaces visual contract", async ({
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 1100 });
|
||||
await page.goto("/examples/states");
|
||||
await expectRouteHeading(page, "화면 상태");
|
||||
await expect(page.getByRole("main")).toHaveScreenshot(
|
||||
"state-surfaces-light.png",
|
||||
);
|
||||
@@ -45,6 +55,7 @@ test("loading empty error and access surfaces visual contract", async ({
|
||||
test("platform composition overview visual contract", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1280, height: 1100 });
|
||||
await page.goto("/examples/platform");
|
||||
await expectRouteHeading(page, "플랫폼 구성");
|
||||
await expect(
|
||||
page.locator("section[aria-labelledby='platform-capabilities-title']"),
|
||||
).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user