Files
clean-architecture-frontend…/tests/e2e/app-shell.spec.ts
T
DongHyeonka 353bed7ac2 fix(design-system): 공통 primitive의 키보드·보조기술 동작을 약속대로 맞춘다
공통 primitive가 디자인 시스템 설계 8.1·8.2절과 WCAG 2.2 AA 약속을
어긴다.

- Popover가 이름 없는 role="dialog"를 그린다(1112/05-10).
- Dialog 안의 Menu·Popover·Tooltip에서 Escape를 누르면 Dialog까지
  닫힌다. Dialog가 안쪽이 처리한 Escape를 보지 않는다(05-11).
- SearchField는 required 기호만, Checkbox는 상태만 있다(05-13).
- Toast를 닫기 버튼으로 닫으면 포커스가 body로 떨어진다(05-14).
- TextArea 글자 수가 <output>(암묵 status)이라 글자마다 발표되고 입력과
  이어지지 않는다(05-17).
- 라우트 h1의 :focus outline 제거가 layer 순서로 키보드 :focus-visible
  표시까지 지운다(05-02). Tooltip이 pointer-events: none과 틈 때문에
  포인터를 설명 위로 옮기면 사라진다(1.4.13, 05-06).
- 홈 readiness 목록이 role 없는 div에 aria-label을 단다(05-15).
- fe-a11y·fe-ux 스킬이 제출 실패 때 오류 요약으로 포커스가 간다고 적는다.
  코드는 첫 오류 필드로 보낸다(05-09).

고른 방법: Popover는 trigger id로 이름을 받는다. Popover·Tooltip은
Escape를 capture 단계에서 받아 preventDefault하고, Dialog는 기본 동작이
막힌 Escape(과 그 뒤 cancel)를 넘긴다. Tooltip은 보일 때(hover·focus)만
Escape를 가진다. 숨은 tooltip이 다른 Dialog의 Escape를 막지 않게 하려는
것이다. Toast 닫기는 다음 toast의 닫기 버튼, 없으면 toast로 들어오기 전
요소로 포커스를 돌린다. TextArea 글자 수는 aria-describedby로 잇고 0에
닿을 때만 따로 발표한다. h1은 :focus:not(:focus-visible)만 outline을
지운다. Tooltip은 보일 때만 포인터를 받고 ::before 다리로 틈을 메운다.
버린 대안: Dialog가 안쪽 layer 목록을 들고 Escape를 나누기(primitive끼리
묶인다).

위험·한계: native <dialog>가 막힌 keydown 뒤에도 cancel을 쏘는지는
브라우저마다 다를 수 있어, Dialog는 같은 task의 cancel 하나를 넘긴다.
Toast가 돌려줄 요소가 지워졌으면 포커스를 옮기지 않는다. 시각 골든이
바뀌는지는 desktop test:visual로 본다.

검증: 새 component 시험(tests/component/design-system-a11y.test.tsx,
starter-pages), e2e(app-shell focus ring, 세 엔진), storybook(tooltip
hover)의 RED·GREEN은 desktop에서 돌려 PR 본문에 적는다.

Refs: 1112/05-02, 1112/05-06, 1112/05-09, 1112/05-10, 1112/05-11,
 1112/05-13, 1112/05-14, 1112/05-15, 1112/05-17
2026-11-12 22:53:40 +09:00

104 lines
4.0 KiB
TypeScript

import { expect, test } from "../support/browser/strict-browser-test.ts";
test("boots the public app shell", async ({ page }) => {
await page.goto("/");
await expect(page.getByRole("heading", { level: 1 })).toHaveText(
"Clean Architecture Frontend",
);
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
await expect(page.getByRole("main")).toBeVisible();
});
test("navigates to a registry-backed example without a page reload", async ({
page,
}) => {
await page.goto("/");
await page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "플랫폼 구성" })
.click();
await expect(page).toHaveURL(/\/examples\/platform$/);
await expect(
page.getByRole("heading", { level: 1, name: "플랫폼 구성" }),
).toBeFocused();
});
// 1112/05-02. The route heading takes focus on every navigation. A keyboard
// user must see it (M2); a pointer user may not need the ring.
test("shows the focus ring on the route heading after keyboard navigation only", async ({
page,
}) => {
await page.goto("/");
const link = page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "플랫폼 구성" });
await link.focus();
await page.keyboard.press("Enter");
const heading = page.getByRole("heading", { level: 1, name: "플랫폼 구성" });
await expect(heading).toBeFocused();
expect(await heading.evaluate((element) => getComputedStyle(element).outlineStyle)).not.toBe("none");
await page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "홈" })
.click();
const home = page.getByRole("heading", { level: 1 });
await expect(home).toBeFocused();
expect(await home.evaluate((element) => getComputedStyle(element).outlineStyle)).toBe("none");
});
test("provides an escape-dismissible mobile navigation", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/");
const menu = page.getByRole("button", { name: "메뉴", exact: true });
await menu.click();
await expect(menu).toHaveAttribute("aria-expanded", "true");
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeVisible();
await expect(page.locator(".ui-drawer")).toHaveJSProperty("open", true);
expect(
await page.locator(".ui-drawer").evaluate((drawer) => drawer.matches(":modal")),
).toBe(true);
await page.keyboard.press("Escape");
await expect(menu).toHaveAttribute("aria-expanded", "false");
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeHidden();
await expect(menu).toBeFocused();
});
// R3-6. A drawer link closes the modal drawer and changes the route in the
// same click. The drawer's deferred focus restore must not win over the new
// page's heading focus; Escape (no navigation) still returns to the menu.
test("moves focus to the new page after a mobile drawer link, not back to the menu", async ({
page,
}) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/");
const menu = page.getByRole("button", { name: "메뉴", exact: true });
const navigation = page.getByRole("navigation", { name: "주요 탐색" });
await menu.click();
await navigation.getByRole("link", { name: "플랫폼 구성" }).click();
await expect(page).toHaveURL(/\/examples\/platform$/);
await expect(menu).toHaveAttribute("aria-expanded", "false");
const heading = page.getByRole("heading", { level: 1, name: "플랫폼 구성" });
await expect(heading).toBeFocused();
// Give any late restore (dialog close timer, lazy route commit) time to run.
await page.waitForTimeout(300);
expect(
await page.evaluate(() => {
const active = document.activeElement;
return active?.matches("h1, main") === true;
}),
).toBe(true);
await expect(menu).not.toBeFocused();
await menu.click();
await expect(navigation).toBeVisible();
await page.keyboard.press("Escape");
await expect(navigation).toBeHidden();
await expect(menu).toBeFocused();
});