Skip to content

test: 테스트마다 sonner 주입 스타일시트를 걷어 역할 조회 지연 해소, 근거 없는 15초 연장 제거 - #62

Merged
chanwoo7 merged 1 commit into
developfrom
test/drop-sonner-style-in-tests
Oct 4, 2026
Merged

chanwoo7 merged 1 commit into
developfrom
test/drop-sonner-style-in-tests

Conversation

@chanwoo7

@chanwoo7 chanwoo7 commented Oct 4, 2026

Copy link
Copy Markdown
Member

배경

  • 릴리즈 chore: 릴리즈 — 검색 칩 관리 화면 #59 뒤 main CI에서 검색 칩 테스트 1건이 5초 제한을 넘겨(5.3초) 이미지 빌드·배포가 건너뛰어졌습니다. 같은 테스트가 PR CI에서도 3.9~4.6초로 한계에 붙어 있었고, 다른 긴 흐름 테스트 3곳에는 근거 없이 15초 연장이 붙어 있었습니다.
  • 계측으로 공통 원인을 찾았습니다.
    • sonner가 import될 때 97규칙짜리 <style>을 문서에 넣습니다(테스트에서 CSS 파일은 비워지므로 문서의 유일한 스타일시트).
    • jsdom은 DOM이 바뀔 때마다 스타일 캐시를 버리고, getComputedStyle에서 문서의 모든 규칙을 다시 대조합니다.
    • 역할·이름 조회(getByRole(..., { name }))는 이름 계산과 보이는지 판단에 조회 1회당 getComputedStyle을 약 139회 부릅니다.
    • 그래서 클릭·입력 직후의 조회마다 규칙 대조 비용이 쌓이고, 병렬·커버리지 부하에서 몇 배로 커졌습니다.

변경

  • 테스트 설정(src/test/setup.ts)의 beforeEach에서 sonner 주입 <style>을 제거합니다. jsdom에서 토스트 CSS는 쓸 데가 없습니다.
  • banners·notifications spec 3곳의 }, 15_000) 연장을 제거했습니다(수정 뒤 0.7~1.3초).
  • 회귀 테스트 src/test/infra/sonner-style.spec.ts: sonner를 불러와도 테스트 시작 시점 문서에 그 스타일시트가 없음.

테스트

  • 계측
    • CPU 프로파일(수정 전 드래그 테스트): 역할 조회 868ms 중 657ms가 jsdom computed-style.js의 규칙 대조
    • 조작 직후 셀 이름 조회 1회: 6668ms → 스타일시트 제거 시 2123ms(DOM 변경이 없으면 3.3ms)
    • 전체 스위트(커버리지, 각 2회): 테스트 시간 합계 133138초 → 99초(−27%), 최장 2.5초 → 1.5초, 1초 초과 4144개 → 21~24개, 실패 0
  • 회귀 테스트는 setup 수정을 되돌리면 실패합니다.
  • pnpm validate 통과(93 files, 1148 tests).

플랜 대조

항목 상태
느린 테스트의 원인 계측과 확정 한 것
원인 제거(sonner 주입 스타일시트) 한 것
근거 없는 15초 연장 3곳 정리 한 것
재발 고정 회귀 테스트 한 것

- 원인(계측): sonner가 import 때 97규칙짜리 <style>을 넣고, jsdom은 DOM이 바뀔 때마다 스타일 캐시를 버려 getComputedStyle이 모든 규칙을 다시 대조. 역할·이름 조회는 조회 1회에 getComputedStyle 약 139회
  - CPU 프로파일: 역할 조회 868ms 중 657ms가 jsdom computed-style.js의 규칙 대조
  - 조작 직후 셀 이름 조회 1회 66~68ms → 스타일시트 제거 시 21~23ms(변경 없으면 3.3ms)
- setup.ts beforeEach에서 해당 <style> 제거. 전체 스위트(커버리지, 2회씩) 합계 133~138초 → 99초, 최장 2.5초 → 1.5초, 1초 초과 41~44개 → 21~24개, 실패 0
- banners·notifications 3곳의 15_000 연장 제거(근거 없던 연장, 수정 후 0.7~1.3초)
- 회귀: sonner를 불러와도 테스트 시작 시점 문서에 그 스타일시트가 없다(setup 수정을 되돌리면 실패 확인)
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: CaQuick/caquick-admin-fe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ff65218-e030-4b05-807f-a1772497a7f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 96.06% (🎯 80%) 2442 / 2542
🟢 Statements 95.53% (🎯 80%) 2675 / 2800
🟢 Functions 94.27% (🎯 80%) 1005 / 1066
🟢 Branches 88.06% (🎯 70%) 2014 / 2287
File CoverageNo changed files found.
Generated in workflow #123 for commit 4780c5a by the Vitest Coverage Report Action

@chanwoo7
chanwoo7 merged commit 8c2bf8f into develop Oct 4, 2026
9 checks passed
@chanwoo7
chanwoo7 deleted the test/drop-sonner-style-in-tests branch October 4, 2026 13:42
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant