Skip to content

test(drawer): add useDrawer interaction and lifecycle coverage#1236

Open
junghyeonsu wants to merge 2 commits intodevfrom
test/use-drawer-coverage
Open

test(drawer): add useDrawer interaction and lifecycle coverage#1236
junghyeonsu wants to merge 2 commits intodevfrom
test/use-drawer-coverage

Conversation

@junghyeonsu
Copy link
Contributor

@junghyeonsu junghyeonsu commented Feb 12, 2026

Summary

  • add a dedicated useDrawer test harness that exercises the hook through realistic interactions
  • increase confidence for future behavior changes by covering drag/release lifecycle and timing-sensitive states

Core Coverage

  • close lifecycle: verifies onOpenChange details, onClose, body pointer-events reset, and delayed onAnimationEnd callback
  • drag gating: verifies drag is blocked when dismissible is false without snap points, and allowed when snap points are configured
  • drag behavior: verifies transform updates and onDrag percentage callback while dragging
  • release behavior: verifies drawer reset path and onRelease(open=true) for non-closing swipe direction
  • snap points: verifies active snap point resets to first snap point after close transition
  • animation flags: verifies hasAnimationDone timing and shouldOverlayAnimate window when fadeFromIndex is 0
  • close button ref: verifies closeButtonRef drives isCloseButtonRendered state correctly

Testing

  • bun test packages/react-headless/drawer/src/useDrawer.test.tsx
  • bun headless:test
  • bun generate:all
  • bun test:all

Summary by CodeRabbit

  • 테스트
    • useDrawer 관련 포괄적인 테스트 스위트가 추가되었습니다. 마운트 상태, 열림/닫힘 콜백과 애니메이션 종료, 해제/드래그 상호작용, 스냅 포인트 동작, 애니메이션 상태 전환, 오버레이 애니메이션 제어 및 포인터/타이머 기반 동작을 검증합니다.

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

⚠️ No Changeset found

Latest commit: 5cfeca4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

useDrawer 훅에 대한 새로운 테스트 파일이 추가되었습니다. DrawerHarness를 통해 마운트 상태, 생명주기 콜백, 드래그/스와이프 상호작용, 스냅 포인트, 애니메이션 및 포인터 캡처 동작을 시뮬레이션합니다.

Changes

Cohort / File(s) Summary
useDrawer Hook Test Suite
packages/react-headless/drawer/src/useDrawer.test.tsx
새로운 테스트 추가(≈341줄). DrawerHarness로 훅 API/DOM을 렌더링해 마운트 플래그, onClose/onOpenChange/onAnimationEnd, dismiss 동작, 드래그(translate3d/포인터 이벤트), onDrag/onRelease, 스냅 포인트 리셋, 애니메이션 상태 및 오버레이 애니메이션 토글을 검증. jest 타이머·포인터 캡처 및 DOM 측정 모킹 사용.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 훅을 품은 상자 열어봤더니 반짝,
드래그로 춤추고 스냅으로 톡톡,
타이머 똑딱, 포인터가 잡고 흔들면,
테스트가 지켜보며 모든 걸 체크하네.
작은 당근 한 조각, 성공을 축하해! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (106 files):

⚔️ .claude/plugins/seed-design/skills~dev (content)
⚔️ .claude/skills~dev (content)
⚔️ .github/workflows/chromatic.yml (content)
⚔️ .github/workflows/deploy-seed-design-docs-alpha-pages.yml (content)
⚔️ .github/workflows/deploy-seed-design-docs-prod-pages.yml (content)
⚔️ .github/workflows/deploy-seed-design-stackflow-spa-alpha-pages.yml (content)
⚔️ .github/workflows/deploy-seed-design-stackflow-spa-prod-pages.yml (content)
⚔️ .github/workflows/deploy-seed-design-storybook-alpha-pages.yml (content)
⚔️ .github/workflows/deploy-seed-design-storybook-prod-pages.yml (content)
⚔️ .github/workflows/react-headless-test.yml (content)
⚔️ .github/workflows/react-test.yml (content)
⚔️ .github/workflows/release-packages.yml (content)
⚔️ .github/workflows/rootage-core-test.yml (content)
⚔️ .github/workflows/sync-figma-entities.yml (content)
⚔️ bun.lock (content)
⚔️ docs/components/component-grid.tsx (content)
⚔️ docs/content/docs/components/(buttons)/action-button.mdx (content)
⚔️ docs/content/docs/components/(buttons)/contextual-floating-button.mdx (content)
⚔️ docs/content/docs/components/(buttons)/floating-action-button.mdx (content)
⚔️ docs/content/docs/components/(buttons)/reaction-button.mdx (content)
⚔️ docs/content/docs/components/(controls)/checkbox.mdx (content)
⚔️ docs/content/docs/components/(controls)/chip.mdx (content)
⚔️ docs/content/docs/components/(controls)/field.mdx (content)
⚔️ docs/content/docs/components/(controls)/input-button.mdx (content)
⚔️ docs/content/docs/components/(controls)/radio.mdx (content)
⚔️ docs/content/docs/components/(controls)/segmented-control.mdx (content)
⚔️ docs/content/docs/components/(controls)/select-box.mdx (content)
⚔️ docs/content/docs/components/(controls)/slider.mdx (content)
⚔️ docs/content/docs/components/(controls)/switch.mdx (content)
⚔️ docs/content/docs/components/(controls)/text-input.mdx (content)
⚔️ docs/content/docs/components/(display)/avatar.mdx (content)
⚔️ docs/content/docs/components/(display)/badge.mdx (content)
⚔️ docs/content/docs/components/(display)/divider.mdx (content)
⚔️ docs/content/docs/components/(display)/manner-temp.mdx (content)
⚔️ docs/content/docs/components/(display)/notification-badge.mdx (content)
⚔️ docs/content/docs/components/(display)/scroll-fog.mdx (content)
⚔️ docs/content/docs/components/(display)/tag-group.mdx (content)
⚔️ docs/content/docs/components/(feedback)/callout.mdx (content)
⚔️ docs/content/docs/components/(feedback)/help-bubble.mdx (content)
⚔️ docs/content/docs/components/(feedback)/page-banner.mdx (content)
⚔️ docs/content/docs/components/(feedback)/progress-circle.mdx (content)
⚔️ docs/content/docs/components/(feedback)/result-section.mdx (content)
⚔️ docs/content/docs/components/(feedback)/skeleton.mdx (content)
⚔️ docs/content/docs/components/(feedback)/snackbar.mdx (content)
⚔️ docs/content/docs/components/(layout)/alert-dialog.mdx (content)
⚔️ docs/content/docs/components/(layout)/bottom-sheet.mdx (content)
⚔️ docs/content/docs/components/(layout)/list.mdx (content)
⚔️ docs/content/docs/components/(layout)/menu-sheet.mdx (content)
⚔️ docs/content/docs/components/(navigation)/bottom-navigation.mdx (content)
⚔️ docs/content/docs/components/(navigation)/tabs.mdx (content)
⚔️ docs/content/docs/components/(navigation)/top-navigation.mdx (content)
⚔️ docs/content/react/getting-started/cli/commands.mdx (content)
⚔️ docs/content/react/getting-started/cli/configuration.mdx (content)
⚔️ docs/public/__registry__/ui/action-button.json (content)
⚔️ docs/public/__registry__/ui/action-sheet.json (content)
⚔️ docs/public/__registry__/ui/alert-dialog.json (content)
⚔️ docs/public/__registry__/ui/app-screen.json (content)
⚔️ docs/public/__registry__/ui/avatar.json (content)
⚔️ docs/public/__registry__/ui/bottom-sheet.json (content)
⚔️ docs/public/__registry__/ui/callout.json (content)
⚔️ docs/public/__registry__/ui/checkbox.json (content)
⚔️ docs/public/__registry__/ui/chip-tabs.json (content)
⚔️ docs/public/__registry__/ui/chip.json (content)
⚔️ docs/public/__registry__/ui/contextual-floating-button.json (content)
⚔️ docs/public/__registry__/ui/control-chip.json (content)
⚔️ docs/public/__registry__/ui/error-state.json (content)
⚔️ docs/public/__registry__/ui/extended-action-sheet.json (content)
⚔️ docs/public/__registry__/ui/field-button.json (content)
⚔️ docs/public/__registry__/ui/floating-action-button.json (content)
⚔️ docs/public/__registry__/ui/help-bubble.json (content)
⚔️ docs/public/__registry__/ui/identity-placeholder.json (content)
⚔️ docs/public/__registry__/ui/index.json (content)
⚔️ docs/public/__registry__/ui/inline-banner.json (content)
⚔️ docs/public/__registry__/ui/list.json (content)
⚔️ docs/public/__registry__/ui/loading-indicator.json (content)
⚔️ docs/public/__registry__/ui/manner-temp-badge.json (content)
⚔️ docs/public/__registry__/ui/manner-temp.json (content)
⚔️ docs/public/__registry__/ui/menu-sheet.json (content)
⚔️ docs/public/__registry__/ui/page-banner.json (content)
⚔️ docs/public/__registry__/ui/progress-circle.json (content)
⚔️ docs/public/__registry__/ui/pull-to-refresh.json (content)
⚔️ docs/public/__registry__/ui/radio-group.json (content)
⚔️ docs/public/__registry__/ui/reaction-button.json (content)
⚔️ docs/public/__registry__/ui/result-section.json (content)
⚔️ docs/public/__registry__/ui/segmented-control.json (content)
⚔️ docs/public/__registry__/ui/select-box.json (content)
⚔️ docs/public/__registry__/ui/slider.json (content)
⚔️ docs/public/__registry__/ui/snackbar.json (content)
⚔️ docs/public/__registry__/ui/switch.json (content)
⚔️ docs/public/__registry__/ui/tabs.json (content)
⚔️ docs/public/__registry__/ui/tag-group.json (content)
⚔️ docs/public/__registry__/ui/text-field.json (content)
⚔️ docs/public/__registry__/ui/toggle-button.json (content)
⚔️ docs/registry/schema.ts (content)
⚔️ docs/scripts/registry-generator.ts (content)
⚔️ package.json (content)
⚔️ packages/cli/package.json (content)
⚔️ packages/cli/src/commands/add-all.ts (content)
⚔️ packages/cli/src/commands/add.ts (content)
⚔️ packages/cli/src/commands/init.ts (content)
⚔️ packages/cli/src/index.ts (content)
⚔️ packages/cli/src/schema.ts (content)
⚔️ packages/cli/src/utils/analytics.ts (content)
⚔️ packages/cli/src/utils/get-config.ts (content)
⚔️ packages/cli/src/utils/get-package-info.ts (content)
⚔️ packages/cli/src/utils/install.ts (content)

These conflicts must be resolved before merging into dev.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Pull request title clearly and concisely describes the main change: adding comprehensive test coverage for useDrawer hook's interactions and lifecycle behaviors.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/use-drawer-coverage
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch test/use-drawer-coverage
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/react-headless/drawer/src/useDrawer.test.tsx (2)

36-68: Biome 정적 분석 오류: 모든 <button>type="button" 명시 필요

테스트 하네스이므로 실제 동작에는 영향이 없지만, Biome가 CI에서 lint/a11y/useButtonType 오류를 6건 보고하고 있습니다. CI가 이를 강제한다면 빌드가 실패할 수 있습니다.

🔧 모든 button에 type="button" 추가
-      <button data-testid="set-open" onClick={() => api.setIsOpen(true)}>
+      <button type="button" data-testid="set-open" onClick={() => api.setIsOpen(true)}>

나머지 5개의 <button>에도 동일하게 type="button"을 추가하세요.


30-32: useEffect 의존성 배열에 api가 포함되어 매 렌더마다 실행될 수 있음

useDrawer가 매 렌더마다 새 객체를 반환한다면, [api, onApi] 의존성으로 인해 이 effect가 매번 실행됩니다. 현재 테스트에서는 onApi가 외부 변수에 할당만 하므로 무한 루프가 발생하지는 않지만, onApi 내부에서 상태를 변경하면 무한 루프가 발생할 수 있습니다. 테스트 전용이므로 크리티컬하지는 않으나 인지해둘 필요가 있습니다.


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 and usage tips.

@junghyeonsu junghyeonsu self-assigned this Feb 13, 2026
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