Commit Graph

2 Commits

  • test: enhance SettingsDialog tests and add App integration test
    Enhanced SettingsDialog component test coverage:
    - Add test for import/export status reset on dialog open
    - Add test for onImportSuccess callback propagation to hook
    - Add test for postponing restart flow (restart later button)
    - Add test for directory management callbacks (browse/reset/change)
    - Expand existing test to cover export, import, and clear actions
    - Fix type safety issues (avoid 'as any', use type guards)
    
    New App.test.tsx integration test:
    - Add comprehensive end-to-end test for main App component
    - Test settings dialog with import success callback and tray menu update
    - Test app switcher between Claude and Codex
    - Test provider CRUD operations (add, edit, delete, duplicate)
    - Test usage script modal workflow
    - Test external website link opening
    - Use vi.hoisted() pattern for centralized mock management
    
    Technical improvements:
    - Remove two environment-dependent tests (DEV flag) that required 'as any'
    - Use proper type guards for optional callback invocation
    - Clean up unused mock variables (switchProviderMock, onImportSuccessMock, refetchPromise)
    - Simplify useProviderActions mock to avoid spread argument type error
    
    Test results: 50 tests passing across 8 test files
  • test: add comprehensive tests for settings dialog components
    Add component tests for ImportExportSection and SettingsDialog with full coverage of UI interactions, state management, and async workflows.
    
    ImportExportSection.test.tsx (5 tests):
    - Verify button states based on file selection
    - Test import/export/clear interactions
    - Validate loading, success, and error UI states
    
    SettingsDialog.test.tsx (5 tests):
    - Test loading state rendering
    - Verify tab navigation and child component callbacks
    - Validate save/cancel workflows with cleanup
    - Test restart prompt and immediate restart flow
    - Use Context Provider pattern to mock Tabs component
    - Mock 7 child components for isolation
    
    Test patterns demonstrated:
    - Complex component isolation with deep mocking
    - Context Provider mocking for UI library components
    - Async workflow validation with waitFor
    - Multi-hook mocking (useSettings + useImportExport)
    
    All 45 tests passing (7 files, 1.13s execution time)