Files
clean-architecture-frontend…/tests
DongHyeonka 7ee1df56f1 test(component): UI 갤러리 화면의 검증·상태 전환을 component 테스트로 막는다 (1101/14.4)
문제: `src/presentation/examples/ui-gallery-page.tsx`는 component 커버리지가
0%였다. e2e(`tests/e2e/ui-gallery.spec.ts`, 폼 검증과 모달 포커스 2건)와
시각 회귀만 이 화면을 봤다. 화면이 primitive에 연결한 규칙(공백 이름 거절,
알림 줄 문구, 알림 숨김·다시 표시, 모달 확인만 알림 줄을 바꿈, 메뉴의 toast)은
게이트 안 단위 실행에서 아무도 확인하지 않았다.

고른 방법: `tests/component/starter-ui-gallery-page.test.tsx` 9건. 화면을
LocaleProvider만으로 그리고 사용자 동작(user-event)으로 확인한다. 섹션 5개와
토큰 7개 렌더, 버튼 3개의 알림 문구, 빈 이름·공백 이름 거절과 trim한 이름
수락, controlled 입력 6종, 알림 숨김·복원, 모달의 취소·닫기·확인, 메뉴 두
항목, 수동 탭 활성화, tooltip 설명. 파일 이름은 starter 화면 테스트 규칙
(`docs/architecture/starter-experience.md`, `starter-*.test.tsx`)을 따라
화면을 지울 때 같이 지운다.
버린 대안: 스냅샷 테스트. 문구가 바뀔 때마다 깨지고 동작은 확인하지 않는다.
앱 라우터(`/examples/ui`)로 띄우기. 라우팅은 router 테스트가 보고, 이
화면은 provider가 locale 하나만 필요하다.
화면 코드는 고치지 않았다.

위험·한계: primitive 자체 동작(포커스 트랩, Esc, 화살표 이동)은 각 primitive
테스트와 e2e가 보고 여기서는 다시 세지 않는다. jsdom이라 실제 레이아웃과
`showModal()`의 top layer는 확인하지 않는다(e2e 몫).

검증:
- 커버리지(`node scripts/run-vitest.ts run tests/component --coverage
  --coverage.include=src/presentation/examples/ui-gallery-page.tsx`):
  전 lines 0/38, functions 0/19, branches 0/8
  후 lines 38/38, functions 19/19, branches 8/8 (100%)
- 일부러 화면을 깨 봄(되돌림): fieldError의 trim 제거, 알림 onDismiss 무효화,
  메뉴 "상태 확인" onSelect 무효화 → 9건 중 3건 실패
- tests/component 전체 38파일 253건 통과
- `npx eslint` 새 파일, `npx tsc --project tsconfig.test.json --noEmit` 통과
2026-11-03 20:09:49 +09:00
..