문제: 접근성 기본 장치 일부를 지키는 테스트가 없었다. 리뷰 변이 중 M3(건너뛰기 링크 대상을 #content로), M4(LoadingSurface의 aria-live 제거), M5(상태 화면 제목을 <p>로), M6(사이드바 aria-label 제거)가 component 211개를 모두 통과했다. e2e의 axe는 WCAG 태그만 돌려 best-practice인 skip-link 규칙이 빠지고, 건너뛰기 링크를 누르는 e2e도 없었다. 고른 방법: 리뷰의 최소 개선 방향 그대로 단언을 더했다. - app-shell.test.tsx: 건너뛰기 링크 href가 main의 id와 같고, 이름 있는 complementary 안에 주요 탐색이 있다. - async-surface.test.tsx: LoadingSurface가 aria-busy와 aria-live="polite"를 가진다. - accessibility.spec.ts: 건너뛰기 링크 Enter 뒤 포커스가 main 안에 있다. - M5는 08-05 커밋의 제목 수준 테스트가 이미 잡는다. 버린 대안: axe에 best-practice 태그를 켜기 — 이번 범위 밖의 위반까지 한꺼번에 게이트가 된다. 위험·한계: 사이드바 이름 "사이드바"는 위치를 말하는 이름이라 리뷰가 관찰로 남겼다. 테스트는 지금 이름을 고정하므로 이름을 바꾸면 테스트도 같이 바꾼다. M3 변이 빌드에서 e2e는 공용 실행 잠금이 길게 잡혀 돌리지 못했다(component 테스트가 M3를 잡는다). 검증(테스트만 추가라 RED는 변이로 확인): - M3: app-shell landmarks 테스트 실패(1 failed | 221 passed) - M4: loading surface 테스트 실패(1 failed | 221 passed) - M5(state-surfaces.tsx 제목을 <p>로): 08-05 테스트 2건 실패 - M6: app-shell landmarks 테스트 실패(1 failed | 221 passed) - 변이 없음: tests/component 222/222, 새 e2e chromium·firefox·webkit 3/3. tsc test 통과, eslint 통과. Refs: docs/reviews/2026-11-01-maturity-review/08-presentation.md 08-09
108 lines
4.2 KiB
TypeScript
108 lines
4.2 KiB
TypeScript
import AxeBuilder from "@axe-core/playwright";
|
|
import { expect, test, type Page } from "../support/browser/strict-browser-test.ts";
|
|
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.ts";
|
|
import type { RouteDefinition } from "../../src/contracts/routes.ts";
|
|
import { KO_MESSAGES } from "../../src/presentation/i18n/catalog.ts";
|
|
|
|
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.
|
|
// Widened: without an installed feature every route is public, and the
|
|
// `session-required` branch must still typecheck (sample removal).
|
|
const ROUTES: readonly RouteDefinition[] = Object.values(ROUTE_REGISTRY);
|
|
for (const definition of ROUTES) {
|
|
const route =
|
|
definition.path === "*"
|
|
? "/not-found"
|
|
: definition.path.replace(":resourceId", "reference-1");
|
|
test(`@a11y ${route} has no critical or serious axe violations`, async ({
|
|
page,
|
|
}) => {
|
|
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([]);
|
|
});
|
|
}
|
|
|
|
test("@a11y keyboard reaches the primary route action with visible focus", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
const action = page.getByRole("link", { name: "플랫폼 구성 보기" });
|
|
await expect(action).toBeVisible();
|
|
await page.keyboard.press("Tab");
|
|
await expect(action).toBeFocused();
|
|
await expect(action).toHaveCSS("outline-style", "solid");
|
|
});
|
|
|
|
// 08-09. axe's skip-link rule is best-practice, outside WCAG_TAGS, so the only
|
|
// way past the header and sidebar (WCAG 2.4.1) needs its own check.
|
|
test("@a11y skip link moves keyboard focus into main", async ({ page }) => {
|
|
await page.goto("/examples/ui");
|
|
await expect(page.getByRole("heading", { level: 1 })).toBeFocused();
|
|
const skipLink = page.getByRole("link", { name: "본문으로 건너뛰기" });
|
|
await skipLink.focus();
|
|
await expect(skipLink).toBeFocused();
|
|
|
|
await page.keyboard.press("Enter");
|
|
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(
|
|
() => document.querySelector("main")?.contains(document.activeElement) ?? false,
|
|
),
|
|
)
|
|
.toBe(true);
|
|
});
|
|
|
|
test("@a11y reduced-motion policy disables long animation", async ({ page }) => {
|
|
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
await page.goto("/");
|
|
const duration = await page
|
|
.locator("body")
|
|
.evaluate((body) => getComputedStyle(body).animationDuration);
|
|
expect(["0s", "0.00001s", "1e-05s"]).toContain(duration);
|
|
});
|
|
|
|
test("@a11y opened design-system dialog has no blocking violations", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/examples/ui");
|
|
await page.getByRole("button", { name: "모달 열기" }).click();
|
|
const results = await new AxeBuilder({ page })
|
|
.include(".ui-dialog")
|
|
.withTags(WCAG_TAGS)
|
|
.analyze();
|
|
expect(
|
|
results.violations.filter((violation) =>
|
|
["critical", "serious"].includes(violation.impact ?? ""),
|
|
),
|
|
).toEqual([]);
|
|
});
|