Merge branch 'fix/r9-primitive-a11y' into fix/r9-form-and-primitives
frontend-quality-gates / merge / static checks (pull_request) Successful in 2m49s
frontend-quality-gates / merge / tests (pull_request) Successful in 15m8s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 7m8s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped

This commit is contained in:
DongHyeonka
2026-11-13 10:28:11 +09:00
21 changed files with 525 additions and 53 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ paths:
폼
- [ ] label·설명·오류가 같은 ID 체계와 `aria-describedby`로 연결된다(M5). required는 기호와 programmatic 상태를 함께 가진다. 제출 실패 시 오류 요약으로 포커스가 간다. — DS 8.3절
- [ ] label·설명·오류가 같은 ID 체계와 `aria-describedby`로 연결된다(M5). required는 기호와 programmatic 상태를 함께 가진다. 입력 오류로 제출이 실패하면 첫 오류 필드로 포커스가 가고, 오류 요약은 그 필드들로 가는 링크다(`src/presentation/forms/use-app-form.ts` `focusFirstError`). 입력 오류가 아닌 실패는 feedback 자리가 포커스를 받는다. — DS 8.3절
- [ ] IME 조합 중에 검증하거나 제출하지 않는다. — DS 8.1절
시각
+1 -1
View File
@@ -58,7 +58,7 @@ paths:
폼
- [ ] label·설명·오류가 연결되고, 제출 실패 시 오류 요약으로 포커스가 가며, 요약 항목은 그 필드로 간다. — `docs/design/2026-07-26-design-system-platform-design.md` 8.3절
- [ ] label·설명·오류가 연결되고, 입력 오류로 제출이 실패하면 첫 오류 필드로 포커스가 가며, 오류 요약 항목은 그 필드로 간다(`src/presentation/forms/use-app-form.ts` `focusFirstError`). — `docs/design/2026-07-26-design-system-platform-design.md` 8.3절
- [ ] 409를 검증 오류로 위장하지 않는다. 이탈 확인(`useDirtyNavigationGuard`)은 성공 저장 뒤 풀고 이동한다. — `docs/design/2026-07-26-typescript-state-and-data-flow-design.md` 8절, `docs/design/2026-07-26-routing-pages-and-patterns-design.md` 6.4절
- [ ] 자동 완성·IME·붙여넣기·비밀번호 관리자를 막지 않는다. 입력을 loading skeleton으로 덮지 않는다. — data-flow 8절
@@ -42,7 +42,11 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
}}
type="checkbox"
/>
<span>{label}</span>
<span>
{label}
{/* 1112/05-13. The symbol as Field draws it; the state is on the input. */}
{props.required ? <span aria-hidden="true"> *</span> : null}
</span>
</label>
{description ? (
<p className="ui-field__description" id={descriptionId}>
@@ -41,6 +41,7 @@ export const Dialog = forwardRef<HTMLDialogElement, DialogProps>(
const dialogRef = useRef<HTMLDialogElement | null>(null);
const previousFocusRef = useRef<HTMLElement | null>(null);
const focusRestoreGenerationRef = useRef(0);
const innerEscapeRef = useRef(false);
const titleId = useId();
const descriptionId = useId();
useImperativeHandle(forwardedRef, () => dialogRef.current!, []);
@@ -103,16 +104,26 @@ export const Dialog = forwardRef<HTMLDialogElement, DialogProps>(
className={`ui-dialog ${className}`.trim()}
onCancel={(event) => {
event.preventDefault();
// The Escape that fired this cancel closed an inner layer.
if (innerEscapeRef.current) return;
onClose();
}}
onClick={(event) => {
if (event.target === event.currentTarget) onClose();
}}
onKeyDown={(event) => {
if (event.key === "Escape") {
event.preventDefault();
onClose();
if (event.key !== "Escape") return;
// 1112/05-11. A Menu, Popover or Tooltip inside handled this Escape
// (it prevented the default): it closes that layer, not the Dialog.
if (event.defaultPrevented) {
innerEscapeRef.current = true;
globalThis.setTimeout(() => {
innerEscapeRef.current = false;
}, 0);
return;
}
event.preventDefault();
onClose();
}}
ref={dialogRef}
>
@@ -0,0 +1,15 @@
/**
* 1112/05-11. Whether an Escape is for a layer drawn over the page (a
* Popover or a shown Tooltip) whose root is `root`. Not when it was pressed
* inside a dialog that does not hold the layer: that Escape is the dialog's.
* An Escape from the layer, from a dialog around it, or from no element
* (focus on the body, as after a click in WebKit) is the layer's.
*/
export function escapeIsForLayer(event: KeyboardEvent, root: Element | null): boolean {
const target = event.target;
if (root === null || !(target instanceof Element) || root.contains(target)) {
return true;
}
const dialog = target.closest("dialog");
return dialog === null || dialog.contains(root);
}
@@ -1,6 +1,7 @@
import { useEffect, useId, useRef, useState } from "react";
import { Button } from "./button.tsx";
import { escapeIsForLayer } from "./escape-layer.ts";
export type PopoverProps = Readonly<{
triggerLabel: string;
@@ -12,6 +13,7 @@ export function Popover({ triggerLabel, children }: PopoverProps) {
const rootRef = useRef<HTMLDivElement | null>(null);
const triggerRef = useRef<HTMLButtonElement | null>(null);
const contentId = useId();
const triggerId = useId();
useEffect(() => {
if (!open) return;
@@ -24,17 +26,25 @@ export function Popover({ triggerLabel, children }: PopoverProps) {
triggerRef.current?.focus();
}
}
// Capture phase, and the default prevented: the Escape closes this
// layer only, not a Dialog around it (1112/05-11). An Escape pressed in
// a Dialog this popover is not in is the Dialog's.
function closeOnEscape(event: KeyboardEvent) {
if (event.key === "Escape") {
if (
event.key === "Escape" &&
!event.defaultPrevented &&
escapeIsForLayer(event, rootRef.current)
) {
event.preventDefault();
setOpen(false);
triggerRef.current?.focus();
}
}
document.addEventListener("pointerdown", closeOutside);
document.addEventListener("keydown", closeOnEscape);
document.addEventListener("keydown", closeOnEscape, true);
return () => {
document.removeEventListener("pointerdown", closeOutside);
document.removeEventListener("keydown", closeOnEscape);
document.removeEventListener("keydown", closeOnEscape, true);
};
}, [open]);
@@ -43,6 +53,7 @@ export function Popover({ triggerLabel, children }: PopoverProps) {
<Button
aria-controls={contentId}
aria-expanded={open}
id={triggerId}
onClick={() => setOpen((current) => !current)}
ref={triggerRef}
variant="secondary"
@@ -50,7 +61,12 @@ export function Popover({ triggerLabel, children }: PopoverProps) {
{triggerLabel}
</Button>
{open ? (
<div className="ui-popover__content" id={contentId} role="dialog">
<div
aria-labelledby={triggerId}
className="ui-popover__content"
id={contentId}
role="dialog"
>
{children}
</div>
) : null}
@@ -47,6 +47,9 @@ export const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
className="ui-field__input"
id={controlId}
ref={inputRef}
// 1112/05-13. Required both ways, as TextField: the symbol
// Field draws and the state on the input.
required={required}
type="search"
value={value}
/>
@@ -45,33 +45,52 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
label={label}
required={required}
>
{({ controlId, describedBy, invalid }) => (
<>
<textarea
{...props}
aria-describedby={describedBy}
aria-invalid={invalid || undefined}
className="ui-field__input ui-field__textarea"
defaultValue={value === undefined ? defaultValue : undefined}
id={controlId}
maxLength={maxLength}
onChange={(event) => {
if (value === undefined) setUncontrolledValue(event.currentTarget.value);
props.onChange?.(event);
}}
ref={ref}
required={required}
value={value}
/>
{remaining !== null ? (
<output className="ui-field__counter">
{maxLengthMessage
? maxLengthMessage(remaining)
: message("form.remaining", { count: remaining })}
</output>
) : null}
</>
)}
{({ controlId, describedBy, invalid }) => {
// 1112/05-17. The count describes the field; it is read when the
// field is reached, not announced on every key. Reaching the limit
// is announced once.
const counterId = `${controlId}-counter`;
const counterText =
remaining === null
? null
: maxLengthMessage
? maxLengthMessage(remaining)
: message("form.remaining", { count: remaining });
return (
<>
<textarea
{...props}
aria-describedby={
[describedBy, counterText === null ? undefined : counterId]
.filter(Boolean)
.join(" ") || undefined
}
aria-invalid={invalid || undefined}
className="ui-field__input ui-field__textarea"
defaultValue={value === undefined ? defaultValue : undefined}
id={controlId}
maxLength={maxLength}
onChange={(event) => {
if (value === undefined) setUncontrolledValue(event.currentTarget.value);
props.onChange?.(event);
}}
ref={ref}
required={required}
value={value}
/>
{counterText !== null ? (
<>
<span className="ui-field__counter" id={counterId}>
{counterText}
</span>
<span aria-live="polite" className="visually-hidden">
{remaining === 0 ? counterText : ""}
</span>
</>
) : null}
</>
);
}}
</Field>
);
},
@@ -4,6 +4,7 @@ import {
useContext,
useEffect,
useMemo,
useRef,
useState,
} from "react";
@@ -79,14 +80,28 @@ function ToastRegion({
dismiss(id: string): void;
}>) {
const { message } = useLocale();
// 1112/05-14. Where focus was before it came into the toasts: closing the
// last toast with its button gives focus back there, not to the body.
const returnFocusRef = useRef<HTMLElement | null>(null);
return (
<section
aria-label={message("toast.region")}
aria-live="polite"
className="ui-toast-region"
onFocus={(event) => {
const from = event.relatedTarget;
if (from instanceof HTMLElement && !event.currentTarget.contains(from)) {
returnFocusRef.current = from;
}
}}
>
{toasts.map((toast) => (
<ToastItem dismiss={dismiss} key={toast.id} toast={toast} />
<ToastItem
dismiss={dismiss}
key={toast.id}
returnFocus={() => returnFocusRef.current}
toast={toast}
/>
))}
</section>
);
@@ -95,9 +110,11 @@ function ToastRegion({
function ToastItem({
toast,
dismiss,
returnFocus,
}: Readonly<{
toast: ToastEntry;
dismiss(id: string): void;
returnFocus(): HTMLElement | null;
}>) {
const { message } = useLocale();
const [paused, setPaused] = useState(false);
@@ -129,7 +146,21 @@ function ToastItem({
</div>
<IconButton
accessibleName={message("action.closeNamed", { title: toast.title })}
onClick={() => dismiss(toast.id)}
onClick={(event) => {
// The button goes away with its toast. Focus moves to the next
// toast's close button, or back to where it came from.
const item = event.currentTarget.closest("article");
const items = item?.parentElement
? [...item.parentElement.querySelectorAll(":scope > article")]
: [];
const index = item ? items.indexOf(item) : -1;
const neighbour = items[index + 1] ?? items[index - 1];
const next =
neighbour?.querySelector("button") ??
(returnFocus()?.isConnected ? returnFocus() : null);
dismiss(toast.id);
next?.focus();
}}
variant="ghost"
>
<CloseIcon />
@@ -1,4 +1,6 @@
import { cloneElement, useEffect, useId, useState } from "react";
import { cloneElement, useEffect, useId, useRef, useState } from "react";
import { escapeIsForLayer } from "./escape-layer.ts";
export type TooltipProps = Readonly<{
content: string;
@@ -7,29 +9,55 @@ export type TooltipProps = Readonly<{
/**
* Describes its focusable child (WCAG 1.4.13): the child carries
* `aria-describedby`, and Escape hides the tooltip until the next hover or
* focus.
* `aria-describedby`, Escape hides the tooltip until the next hover or
* focus, and the pointer can move onto the tooltip (primitives.css).
*/
export function Tooltip({ content, children }: TooltipProps) {
const tooltipId = useId();
const [dismissed, setDismissed] = useState(false);
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const rootRef = useRef<HTMLSpanElement | null>(null);
const shown = (hovered || focused) && !dismissed;
useEffect(() => {
if (dismissed) return;
// Document level: a hovered trigger does not have keyboard focus.
if (!shown) return;
// Document level: a hovered trigger does not have keyboard focus. Capture
// phase, and the default prevented: this Escape hides the tooltip only,
// not a Dialog around it (1112/05-11). A tooltip that is not shown, or
// one outside the Dialog the Escape was pressed in, leaves it alone.
function dismissOnEscape(event: KeyboardEvent) {
if (event.key === "Escape") setDismissed(true);
if (
event.key !== "Escape" ||
event.defaultPrevented ||
!escapeIsForLayer(event, rootRef.current)
) {
return;
}
event.preventDefault();
setDismissed(true);
}
document.addEventListener("keydown", dismissOnEscape);
return () => document.removeEventListener("keydown", dismissOnEscape);
}, [dismissed]);
document.addEventListener("keydown", dismissOnEscape, true);
return () => document.removeEventListener("keydown", dismissOnEscape, true);
}, [shown]);
const describedBy = [children.props["aria-describedby"], tooltipId]
.filter(Boolean)
.join(" ");
return (
<span
className="ui-tooltip"
onFocus={() => setDismissed(false)}
onMouseEnter={() => setDismissed(false)}
ref={rootRef}
onBlur={(event) => {
if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
}}
onFocus={() => {
setFocused(true);
setDismissed(false);
}}
onMouseEnter={() => {
setHovered(true);
setDismissed(false);
}}
onMouseLeave={() => setHovered(false)}
>
{cloneElement(children, { "aria-describedby": describedBy })}
<span
+1 -1
View File
@@ -53,7 +53,7 @@ export default function HomePage() {
title={message("route.APP_HOME.title")}
description={message("home.description")}
/>
<div className="readiness-grid" aria-label={message("home.readiness")}>
<div className="readiness-grid" role="group" aria-label={message("home.readiness")}>
{READINESS_ITEMS.map((item) => (
<article className="ui-panel" key={item}>
<h2>{message(`home.readiness.${item}.title`)}</h2>
@@ -516,9 +516,21 @@
transition: opacity var(--duration-fast) var(--easing-standard);
}
/* 1112/05-06. WCAG 1.4.13 hoverable: a shown tooltip takes the pointer,
and the bridge below it covers the gap to the trigger, so moving onto it
keeps .ui-tooltip hovered. A hidden one stays out of the pointer's way. */
.ui-tooltip__content::before {
position: absolute;
inset-inline: 0;
inset-block-start: 100%;
block-size: var(--space-2);
content: "";
}
.ui-tooltip:focus-within .ui-tooltip__content,
.ui-tooltip:hover .ui-tooltip__content {
opacity: 1;
pointer-events: auto;
}
.ui-progress,
+3 -1
View File
@@ -4,7 +4,9 @@
padding-block: clamp(1rem, 5vw, 3.5rem) 0.5rem;
}
[data-route-heading]:focus {
/* 1112/05-02. Pointer navigation only: a keyboard user keeps the
:focus-visible ring (base.css) on the heading each route move focuses. */
[data-route-heading]:focus:not(:focus-visible) {
outline: none;
}
+270
View File
@@ -0,0 +1,270 @@
// @vitest-environment jsdom
import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { useState } from "react";
import { describe, expect, it, vi } from "vitest";
import {
Button,
Checkbox,
Dialog,
Menu,
Popover,
SearchField,
TextArea,
ToastProvider,
Tooltip,
useToast,
} from "../../src/presentation/design-system/index.ts";
/**
* 1112/05-10, 05-11, 05-13, 05-14, 05-17. What the shared primitives promise
* a keyboard and screen reader user (docs/design/2026-07-26-design-system-platform-design.md
* 8.1·8.2절, WCAG 2.2 AA): a named dialog, Escape that closes the innermost
* layer only, required shown both ways, focus that does not fall to the body,
* and a counter that is not announced on every key.
*/
function DialogWith({ onClose, children }: Readonly<{ onClose(): void; children: React.ReactNode }>) {
return (
<Dialog open onClose={onClose} title="설정">
{children}
</Dialog>
);
}
describe("Popover", () => {
it("names its dialog after the trigger", async () => {
const user = userEvent.setup();
render(
<Popover triggerLabel="설명 열기">
<Button>내부 작업</Button>
</Popover>,
);
await user.click(screen.getByRole("button", { name: "설명 열기" }));
expect(screen.getByRole("dialog", { name: "설명 열기" })).toBeVisible();
});
});
describe("Escape inside a Dialog", () => {
it("closes an open Popover and keeps the Dialog", async () => {
const user = userEvent.setup();
const onClose = vi.fn();
render(
<DialogWith onClose={onClose}>
<Popover triggerLabel="설명 열기">
<Button>내부 작업</Button>
</Popover>
</DialogWith>,
);
await user.click(screen.getByRole("button", { name: "설명 열기" }));
await user.click(screen.getByRole("button", { name: "내부 작업" }));
await user.keyboard("{Escape}");
expect(screen.queryByRole("button", { name: "내부 작업" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "설명 열기" })).toHaveFocus();
expect(onClose).not.toHaveBeenCalled();
});
it("closes an open Menu and keeps the Dialog", async () => {
const user = userEvent.setup();
const onClose = vi.fn();
render(
<DialogWith onClose={onClose}>
<Menu triggerLabel="더 보기" items={[{ id: "copy", label: "복사", onSelect: () => {} }]} />
</DialogWith>,
);
await user.click(screen.getByRole("button", { name: "더 보기" }));
expect(screen.getByRole("menu")).toBeVisible();
await user.keyboard("{Escape}");
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
expect(onClose).not.toHaveBeenCalled();
});
it("hides a shown Tooltip and keeps the Dialog", async () => {
const user = userEvent.setup();
const onClose = vi.fn();
render(
<DialogWith onClose={onClose}>
<Tooltip content="자세한 설명">
<Button>도움말</Button>
</Tooltip>
</DialogWith>,
);
await user.hover(screen.getByRole("button", { name: "도움말" }));
await user.keyboard("{Escape}");
expect(screen.getByRole("tooltip", { hidden: true })).not.toBeVisible();
expect(onClose).not.toHaveBeenCalled();
});
// round9 confirm review. A popover or tooltip left open outside a Dialog
// does not take the Dialog's Escape: the Escape belongs to the Dialog it
// was pressed in.
it.each([
[
"a Popover",
(
<Popover key="layer" triggerLabel="설명 열기">
<Button>내부 작업</Button>
</Popover>
),
(user: ReturnType<typeof userEvent.setup>) => user.click(screen.getByRole("button", { name: "설명 열기" })),
],
[
"a Tooltip",
(
<Tooltip key="layer" content="자세한 설명">
<Button>도움말</Button>
</Tooltip>
),
(user: ReturnType<typeof userEvent.setup>) => user.hover(screen.getByRole("button", { name: "도움말" })),
],
])("closes the Dialog when %s outside it is open", async (_label, layer, openLayer) => {
const user = userEvent.setup();
const onClose = vi.fn();
render(
<>
{layer}
<DialogWith onClose={onClose}>
<Button>안쪽 버튼</Button>
</DialogWith>
</>,
);
await openLayer(user);
screen.getByRole("button", { name: "안쪽 버튼" }).focus();
await user.keyboard("{Escape}");
expect(onClose).toHaveBeenCalledTimes(1);
});
// WebKit does not focus a clicked button: an Escape with focus on the body
// still closes the open Popover.
it("closes an open Popover on an Escape from the body", async () => {
const user = userEvent.setup();
render(
<Popover triggerLabel="설명 열기">
<Button>내부 작업</Button>
</Popover>,
);
await user.click(screen.getByRole("button", { name: "설명 열기" }));
(document.activeElement as HTMLElement | null)?.blur();
await user.keyboard("{Escape}");
expect(screen.queryByRole("button", { name: "내부 작업" })).not.toBeInTheDocument();
});
it("closes the Dialog when no inner layer is open", async () => {
const user = userEvent.setup();
const onClose = vi.fn();
render(
<DialogWith onClose={onClose}>
<Button>안쪽 버튼</Button>
</DialogWith>,
);
screen.getByRole("button", { name: "안쪽 버튼" }).focus();
await user.keyboard("{Escape}");
expect(onClose).toHaveBeenCalledTimes(1);
});
});
describe("required fields", () => {
it("marks a required SearchField both on the input and with the symbol", () => {
render(<SearchField label="검색" required value="" onChange={() => {}} clearLabel="지우기" onClear={() => {}} />);
expect(screen.getByRole("searchbox", { name: /검색/u })).toBeRequired();
expect(screen.getByText("*", { exact: false })).toHaveAttribute("aria-hidden", "true");
});
it("marks a required Checkbox both on the input and with the symbol", () => {
render(<Checkbox label="약관에 동의" required />);
const checkbox = screen.getByRole("checkbox", { name: /약관에 동의/u });
expect(checkbox).toBeRequired();
const label = checkbox.closest("label");
if (!label) throw new Error("expected the checkbox label");
expect(within(label).getByText("*", { exact: false })).toHaveAttribute("aria-hidden", "true");
});
});
describe("Toast focus when it is closed", () => {
function Harness({ count }: Readonly<{ count: number }>) {
const toast = useToast();
return (
<Button
onClick={() => {
for (let index = 0; index < count; index += 1) {
toast.push({ id: `toast-${index}`, title: `알림 ${index}`, durationMs: 60_000 });
}
}}
>
알림 보이기
</Button>
);
}
it("moves focus to the next toast's close button", async () => {
const user = userEvent.setup();
render(
<ToastProvider>
<Harness count={2} />
</ToastProvider>,
);
await user.click(screen.getByRole("button", { name: "알림 보이기" }));
const [first] = screen.getAllByRole("button", { name: /닫기/u });
if (!first) throw new Error("expected two close buttons");
first.focus();
await user.click(first);
expect(document.activeElement).not.toBe(document.body);
expect(document.activeElement).toBe(screen.getByRole("button", { name: /닫기/u }));
});
it("returns focus to where it was before the last toast took it", async () => {
const user = userEvent.setup();
render(
<ToastProvider>
<Harness count={1} />
</ToastProvider>,
);
const trigger = screen.getByRole("button", { name: "알림 보이기" });
await user.click(trigger);
await user.tab();
const close = screen.getByRole("button", { name: /닫기/u });
expect(close).toHaveFocus();
await user.keyboard("{Enter}");
expect(screen.queryByRole("article")).not.toBeInTheDocument();
expect(trigger).toHaveFocus();
});
});
describe("TextArea counter", () => {
it("describes the field without announcing every key", async () => {
const user = userEvent.setup();
function Controlled() {
const [value, setValue] = useState("");
return <TextArea label="메모" maxLength={30} value={value} onChange={(event) => setValue(event.currentTarget.value)} />;
}
render(<Controlled />);
const field = screen.getByRole("textbox", { name: "메모" });
await user.type(field, "가나다");
expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(field).toHaveAccessibleDescription(/27/u);
});
});
+11 -1
View File
@@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, it } from "vitest";
import { LocaleProvider } from "../../src/presentation/i18n/index.ts";
import { formatMessage, LocaleProvider } from "../../src/presentation/i18n/index.ts";
import HomePage from "../../src/presentation/pages/home-page.tsx";
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
import { PreferenceProviders } from "../../src/presentation/providers/preference-providers.tsx";
@@ -35,6 +35,16 @@ function renderApp(
}
describe("starter home page", () => {
// 1112/05-15. A generic div's aria-label is dropped by assistive technology;
// the readiness list is a named group.
it("names the readiness list as a group", async () => {
renderApp("/");
expect(
await screen.findByRole("group", { name: formatMessage("ko-KR", "home.readiness") }),
).toBeVisible();
});
it("reaches the platform overview from the starter actions", async () => {
const user = userEvent.setup();
renderApp("/");
+28
View File
@@ -24,6 +24,34 @@ test("navigates to a registry-backed example without a page reload", async ({
).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("/");
// The home route renders after the shell: focus given before it is there
// goes with the node it lands on, and Enter then does nothing (WebKit).
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Clean Architecture Frontend");
const link = page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "플랫폼 구성" });
await link.focus();
await expect(link).toBeFocused();
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("/");
+23
View File
@@ -23,6 +23,29 @@ async function openDesignSystemGallery(page: Page) {
).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();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 123 KiB