Skip to content

test: added test cases for seperator, sheet, sidebar

srilatha bandari requested to merge test/seperator-sheet-sidebar into test_cases

Description:

This PR adds comprehensive unit test cases for UI components located in src/components/ui:

  • separator.tsx (22 tests)
  • sheet.tsx (37 tests)
  • sidebar.tsx (79 tests)

Separator Tests

  • Covers rendering, orientation (horizontal/vertical), styling via cn() utility, and accessibility (role, aria-orientation)
  • Tests decorative vs non-decorative modes
  • Handles edge cases like empty props, multiple renders, and ref forwarding

Sheet Tests

  • Covers rendering, trigger behavior, and visibility (open/close)
  • User interactions: click, Escape key, overlay click
  • Supports variants (top, bottom, left, right)
  • Controlled/uncontrolled behavior with open and onOpenChange
  • Accessibility (dialog role, focus handling)
  • Portal rendering and async behavior handling

Sidebar Tests

  • Covers complex sidebar behavior with context provider
  • Tests open/close state, controlled mode, and callbacks
  • UI rendering for header, footer, menu, groups, and actions
  • Keyboard shortcuts (Ctrl/Cmd + B)
  • Mobile responsiveness (sheet-based behavior)
  • Accessibility (aria-labels, sr-only text)
  • Edge cases: rapid toggling, multiple instances, null props
  • Integration with hooks (e.g., useIsMobile) and persistence logic

Key Highlights

  • Total: 138 tests
  • Uses Jest + React Testing Library
  • Real component implementations are tested (minimal mocking)
  • External dependencies (hooks, i18n, utilities) are mocked where needed
  • Focus on UI behavior, accessibility, and edge cases

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-29_12-18-13


Checklist:

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

closes #280 (closed)

Merge request reports

Loading