test: added test cases for dialog and drawer
Description:
This PR adds comprehensive unit test cases for UI components:
-
dialog.tsx(Radix UI-based modal) -
drawer.tsx(Vaul-based bottom sheet)
The tests ensure full coverage of rendering, user interactions, controlled/uncontrolled behavior, accessibility, edge cases, and integration with utility functions.
Dialog Tests (dialog.test.tsx)
-
Total: 43 tests
-
Covers:
- Rendering (dialog structure, header, footer, overlay, portal)
- User interactions (open, close, Escape key, overlay click)
- Controlled & uncontrolled states (
open,defaultOpen,onOpenChange) - Conditional UI rendering
- Callback validations
- Accessibility (
role="dialog", focus, labels) - Edge cases (rapid toggling, null children, empty values)
- Component-specific behavior (
asChildsupport) - Integration with
cnutility - Complete dialog lifecycle flow
Drawer Tests (drawer.test.tsx)
-
Total: 51 tests
-
Covers:
- Rendering (drawer structure, handle, overlay, portal)
- User interactions (open, close, Escape key, overlay click)
- Controlled & uncontrolled states
- Conditional UI rendering
- Callback validations
- Accessibility compliance
- Edge cases
- Component-specific behavior (
asChild) - Integration testing (
cnutility,shouldScaleBackground) - Complete drawer lifecycle flow
Key Highlights
- Tests use Jest + React Testing Library
- Only external UI primitives (Radix/Vaul) are mocked
- Actual component implementations are tested for accurate coverage
- All sub-components are validated (Trigger, Content, Header, Footer, Title, Description, Close, Overlay, Portal)
Type of Change:
-
Bug Fix -
Feature Development -
Documentation
Testing:
-
Tested on desktop -
Tested on mobile -
Tested in different browsers
Screenshots (if applicable):
Checklist:
-
Code follows project style guidelines -
Self-review completed -
No console errors -
TypeScript types are correct
closes #272 (closed)
