Files
DongHyeonka 2f3ebba46b test(storybook): 배럴의 모든 화면 컴포넌트에 story를 두고 저장 상태를 골든에 넣는다
디자인 시스템 배럴(`src/presentation/design-system/index.ts`)의 값 export
가운데 화면 컴포넌트 37개에 story가 없다: SearchField·ConfirmationDialog·
Drawer·Popover·Breadcrumbs·Pagination·LinkButton·Separator·IconButton 같은
primitive, DataTable 등 pattern 다섯, 페이지 템플릿 다섯, 폼 구성요소, 아이콘
아홉. 결과를 모르는 저장(확인·같은 요청 다시 보내기), 충돌, 오래된 데이터,
저장 중은 갤러리와 골든에 없다. 그래서 파생 서비스가 쓸 컴포넌트의 상태를 볼
곳이 없고, 그 배치 회귀를 골든이 잡지 못한다.

고른 방법:
- `catalog.stories.tsx`에 묶음 story 열을 더한다(겹치는 화면, 탐색과 입력,
  아이콘, 화면 패턴, 페이지 템플릿 다섯을 하나씩, 저장 결과). 템플릿 story는
  각자 자기 h1을 그린다.
- ScreenStates 갤러리에 저장 상태 절을 더한다: 결과를 모르는 저장(다시 보내기
  가능), 충돌, 오래된 데이터, 저장 중, 입력과 무관한 저장 실패
  (FormFailureStatus), 입력 오류 요약. `state-surfaces-light` 골든이 이 절을
  담는다.
- `tests/unit/design-system-story-coverage.test.ts`가 배럴의 값 export마다
  story에서 `<Name`으로 그려지는지 대조한다. 그리지 않는 것(Portal·FocusRing·
  VisuallyHidden, 토큰 상수, hook)은 이유와 함께 목록에 둔다.
- 새 story 열은 `tests/storybook/galleries.spec.ts`의 axe 검사(light·dark)에
  더했고, 겹치는 화면 셋(확인 대화 상자, 서랍, 팝오버)은 연 상태로도 본다.
  대조 시험이 catalog story마다 그 목록에 있는지 본다.
- 갤러리에 넣으면서 드러난 둘을 고쳤다. 저장 상태 안내의 문장과 버튼이 붙어
  있었다(`.async-surface__status`: 한 줄로 감싸고 간격, 지원 참조는 아랫줄).
  `FormFailureStatus`가 제목 단계를 받지 못해 카드 안에서 h2로 그려졌다
  (`headingLevel`, 추가만, 다른 상태 표면과 같은 08-05 계약).
- 버린 대안: 컴포넌트마다 variant 행렬 story를 한 번에 쓰기(이번 범위는 "모든
  화면 컴포넌트에 story 하나 이상"이고, 행렬은 컴포넌트를 고칠 때 더한다).
  StatusPage를 갤러리에 넣기(자기 h1을 그려 갤러리의 h1과 겹친다. 자기
  story로 뒀다).

위험·한계: 갤러리 골든이 바뀐다(이 커밋에서 다시 찍는다). theme·locale
toolbar는 아직 없다. story axe가 20번 늘어 FE-GATE-008이 조금 길어진다.

검증: 대조 시험(고치기 전 story 파일에서 37개 누락으로 실패), story 빌드
(FE-GATE-011), story axe와 시각 골든(FE-GATE-008)은 desktop에서 돌려 PR
본문에 적는다.

Refs: 1112/04-10
2026-11-13 23:27:47 +09:00

197 lines
8.4 KiB
TypeScript

import AxeBuilder from "@axe-core/playwright";
import { WCAG_AXE_TAGS } from "../support/browser/axe-tags.ts";
import {
expect,
test,
type Page,
} from "../support/browser/strict-browser-test.ts";
/**
* The design-system gallery (src/presentation/design-system/galleries.stories.tsx)
* in a real browser. These checks ran on the template's example screen
* `/examples/ui` until the galleries became workshop stories; the primitives
* keep their own component suites. The a11y addon's own axe run is switched
* off, as in workshop.spec.ts: the dialog check below owns it.
*/
async function openDesignSystemGallery(page: Page) {
await page.goto(
"/iframe.html?id=platform-galleries--design-system&viewMode=story&globals=a11y.manual:!true",
);
await expect(
page.getByRole("heading", { level: 1, name: "UI 구성요소" }),
).toBeVisible();
}
// 1112/05-06. WCAG 1.4.13 hoverable: the pointer can move from the trigger
// onto the tooltip, across the gap between them, and the tooltip stays.
test("keeps a tooltip shown while the pointer moves onto it", async ({ page }) => {
await openDesignSystemGallery(page);
await page.getByRole("button", { name: "도움말" }).hover();
const tooltip = page.getByRole("tooltip", { name: "이 설명은 필수 정보가 아닙니다." });
await expect.poll(() => tooltip.evaluate((element) => getComputedStyle(element).opacity)).toBe("1");
const box = await tooltip.boundingBox();
if (!box) throw new Error("expected the tooltip box");
// The hover that shows it holds in the gap and over the tooltip itself:
// read where it is decided, not only the opacity, which fades over 100 ms
// and still reads 1 the moment the hover is lost.
const stillHovered = () =>
tooltip.evaluate((element) => element.closest(".ui-tooltip")?.matches(":hover") ?? false);
await page.mouse.move(box.x + box.width / 2, box.y + box.height + 2, { steps: 4 });
expect(await stillHovered()).toBe(true);
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 4 });
expect(await stillHovered()).toBe(true);
await expect.poll(() => tooltip.evaluate((element) => getComputedStyle(element).opacity)).toBe("1");
});
test("validates and reports the common text-field flow", async ({ page }) => {
await openDesignSystemGallery(page);
await page.getByRole("button", { name: "입력 확인" }).click();
const field = page.getByRole("textbox", { name: "프로젝트 이름" });
await expect(field).toHaveAttribute("aria-invalid", "true");
await expect(field).toHaveAccessibleDescription(
/프로젝트 이름을 입력해 주세요/,
);
await field.fill("Starter");
await page.getByRole("button", { name: "입력 확인" }).click();
await expect(page.getByText("“Starter” 입력을 확인했습니다.")).toBeVisible();
});
test("traps modal interaction and restores focus to the trigger", async ({
page,
}) => {
await openDesignSystemGallery(page);
const trigger = page.getByRole("button", { name: "모달 열기" });
await trigger.click();
const dialog = page.getByRole("dialog", { name: "연동 확인" });
await expect(dialog).toBeVisible();
await expect(
dialog.getByRole("button", { name: "연동 확인 닫기" }),
).toBeFocused();
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
await expect(trigger).toBeFocused();
});
test("opened design-system dialog has no blocking violations", async ({
page,
}) => {
await openDesignSystemGallery(page);
await page.getByRole("button", { name: "모달 열기" }).click();
const results = await new AxeBuilder({ page })
.include(".ui-dialog")
.withTags([...WCAG_AXE_TAGS])
.analyze();
expect(
results.violations.filter((violation) =>
["critical", "serious"].includes(violation.impact ?? ""),
),
).toEqual([]);
});
// 1112/04-10. The catalog's overlays are scanned open, as the gallery dialog is.
for (const overlay of [
{ open: "항목 삭제", layer: ".ui-dialog", name: "이 항목을 삭제할까요?" },
{ open: "서랍 열기", layer: ".ui-drawer", name: "필터" },
{ open: "도움말", layer: ".ui-popover", name: "도움말" },
] as const) {
test(`opened catalog overlay "${overlay.name}" has no blocking violations`, async ({ page }) => {
await page.goto("/iframe.html?id=platform-catalog--overlays&viewMode=story&globals=a11y.manual:!true");
await expect(page.getByRole("heading", { level: 1, name: "겹치는 화면" })).toBeVisible();
await page.getByRole("button", { name: overlay.open }).click();
await expect(page.getByRole("dialog", { name: overlay.name })).toBeVisible();
const results = await new AxeBuilder({ page })
.include(overlay.layer)
.withTags([...WCAG_AXE_TAGS])
.analyze();
expect(
results.violations.filter((violation) =>
["critical", "serious"].includes(violation.impact ?? ""),
),
).toEqual([]);
});
}
// 1112/05-04. The galleries replaced the example screens, whose whole page
// the route scan checked. With no feature installed they are the only place
// the empty, error, sign-in and access surfaces are drawn, so the whole story
// is scanned, in both colour schemes, as the screens were.
for (const story of [
{ id: "platform-galleries--design-system", heading: "UI 구성요소" },
{ id: "platform-galleries--screen-states", heading: "화면 상태" },
// 1112/04-10. The catalog: every barrel component outside the galleries.
{ id: "platform-catalog--overlays", heading: "겹치는 화면" },
{ id: "platform-catalog--navigation-and-controls", heading: "탐색과 입력" },
{ id: "platform-catalog--icons", heading: "의미 아이콘" },
{ id: "platform-catalog--patterns", heading: "화면 패턴" },
{ id: "platform-catalog--standard-template", heading: "기본 페이지" },
{ id: "platform-catalog--collection-template", heading: "목록 페이지" },
{ id: "platform-catalog--detail-template", heading: "상세 페이지" },
{ id: "platform-catalog--form-template", heading: "폼 페이지" },
{ id: "platform-catalog--status-template", heading: "로그인이 필요합니다." },
{ id: "platform-catalog--form-feedback", heading: "저장 결과" },
] as const) {
for (const colorScheme of ["light", "dark"] as const) {
test(`${story.id} has no blocking violations in ${colorScheme}`, async ({ page }) => {
await page.emulateMedia({ colorScheme });
await page.goto(`/iframe.html?id=${story.id}&viewMode=story&globals=a11y.manual:!true`);
await expect(page.getByRole("heading", { level: 1, name: story.heading })).toBeVisible();
const results = await new AxeBuilder({ page })
.withTags([...WCAG_AXE_TAGS])
.analyze();
expect(
results.violations
.filter((violation) => ["critical", "serious"].includes(violation.impact ?? ""))
.map((violation) => `${violation.id}: ${violation.nodes.map((node) => node.target.join(" ")).join(", ")}`),
).toEqual([]);
});
}
}
test("runs menu typeahead, tabs and duplicate toast interactions", async ({
page,
}) => {
await openDesignSystemGallery(page);
const menuTrigger = page.getByRole("button", { name: "작업 메뉴" });
await menuTrigger.focus();
await page.keyboard.press("ArrowDown");
await page.keyboard.type("toast");
const toastItem = page.getByRole("menuitem", { name: "Toast 표시" });
await expect(toastItem).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.getByText("예제가 저장되었습니다.")).toBeVisible();
await expect(menuTrigger).toBeFocused();
const tokenTab = page.getByRole("tab", { name: "토큰" });
await tokenTab.focus();
await page.keyboard.press("ArrowRight");
const primitiveTab = page.getByRole("tab", { name: "프리미티브" });
await expect(primitiveTab).toBeFocused();
await expect(primitiveTab).toHaveAttribute("aria-selected", "false");
await page.keyboard.press("Enter");
await expect(primitiveTab).toHaveAttribute("aria-selected", "true");
await expect(
page.getByRole("tabpanel", { name: "프리미티브" }),
).toContainText("native semantics");
});
test("reflows the gallery at the 320px minimum without horizontal overflow", async ({
page,
}) => {
await page.setViewportSize({ width: 320, height: 720 });
await openDesignSystemGallery(page);
const viewport = await page.evaluate(() => ({
clientWidth: document.documentElement.clientWidth,
scrollWidth: document.documentElement.scrollWidth,
}));
expect(viewport.scrollWidth).toBeLessThanOrEqual(viewport.clientWidth);
});