From ba98048b29fb0a3eb962046d335823935d0e08aa Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 1 Nov 2026 22:42:00 +0900 Subject: [PATCH] =?UTF-8?q?test(design-system):=20Popover=20=ED=8F=AC?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=20=EB=B0=98=ED=99=98=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EA=B0=80=20=EC=A0=84=EC=A0=9C=EB=A5=BC=20=EB=A8=BC?= =?UTF-8?q?=EC=A0=80=20=EB=A7=8C=EB=93=A0=EB=8B=A4=20(10-02)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: "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 --- tests/component/design-system-platform.test.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/component/design-system-platform.test.tsx b/tests/component/design-system-platform.test.tsx index ef11d35c..b13888eb 100644 --- a/tests/component/design-system-platform.test.tsx +++ b/tests/component/design-system-platform.test.tsx @@ -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();