test(design-system): Popover 포커스 반환 테스트가 전제를 먼저 만든다 (10-02)
문제: "Escape 뒤 포커스가 trigger로 돌아온다" 단언은 trigger를 클릭한 채로 Escape를 누른다. Popover는 열 때 포커스를 내용으로 옮기지 않으므로 포커스는 처음부터 끝까지 trigger에 있다. overlays.tsx의 Escape 처리에서 `triggerRef.current?.focus()`를 지워도(M15) 관련 테스트가 모두 통과한다. 내용 안의 버튼으로 Tab한 뒤 Escape를 누르는 키보드 사용자는 포커스를 잃어도 아무 테스트가 모른다(WCAG 2.4.3). 고른 방법: 열고 나서 Tab으로 내용 안의 "내부 작업" 버튼에 포커스를 옮기고, 그 버튼에 포커스가 있는지 먼저 단언한다. 그 뒤 Escape와 trigger 포커스 단언은 그대로 둔다. 리뷰 최소 개선안 그대로다. 위험·한계: 바깥 클릭으로 닫을 때의 포커스 반환(closeOutside)은 이 테스트가 보지 않는다. 이번 발견 범위 밖이다. 검증: - RED(M15 적용): 변경 전 테스트 파일은 통과, 새 테스트는 "expect(element).toHaveFocus()" 실패(design-system-platform.test.tsx trigger 단언). - GREEN: 원본 overlays.tsx로 되돌리고 related overlays.tsx --run — 23파일 152 passed. - eslint(바꾼 파일), tsc -p tsconfig.test.json 통과. Refs: docs/reviews/2026-11-01-maturity-review/10-tests-fast-layers.md 10-02
This commit is contained in:
@@ -320,6 +320,10 @@ describe("design-system platform interactions", () => {
|
||||
const popoverTrigger = screen.getByRole("button", { name: "설명 열기" });
|
||||
await user.click(popoverTrigger);
|
||||
expect(screen.getByRole("dialog")).toHaveTextContent("내부 작업");
|
||||
// 10-02. Opening leaves focus on the trigger, so move it into the content
|
||||
// first; otherwise the check below holds whatever Escape does.
|
||||
await user.tab();
|
||||
expect(screen.getByRole("button", { name: "내부 작업" })).toHaveFocus();
|
||||
await user.keyboard("{Escape}");
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
expect(popoverTrigger).toHaveFocus();
|
||||
|
||||
Reference in New Issue
Block a user