Skip to content

test: added test cases for dialog and drawer

srilatha bandari requested to merge test/dialog-drawer into test_cases

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 (asChild support)
    • Integration with cn utility
    • 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 (cn utility, 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):

Screenshot_from_2026-03-28_11-21-38


Checklist:

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • TypeScript types are correct

closes #272 (closed)

Merge request reports

Loading