Commit Graph

3 Commits

  • test: update test suites to match component refactoring
    Comprehensive test updates to align with recent component refactoring
    and new auto-launch functionality.
    
    Component Tests:
    - AddProviderDialog.test.tsx (10 lines):
      * Updated test cases for new dialog behavior
      * Enhanced mock data for preset selection
      * Improved assertions for validation
    
    - ImportExportSection.test.tsx (16 lines):
      * Updated for new settings page integration
      * Enhanced test coverage for error scenarios
      * Better mock state management
    
    - McpFormModal.test.tsx (60 lines):
      * Extensive updates for form refactoring
      * New test cases for multi-app selection
      * Enhanced validation testing
      * Better coverage of stdio/http server types
    
    - ProviderList.test.tsx (11 lines):
      * Updated for new card layout
      * Enhanced drag-and-drop testing
    
    - SettingsDialog.test.tsx (96 lines):
      * Major updates for SettingsPage migration
      * New test cases for auto-launch functionality
      * Enhanced integration test coverage
      * Better async operation testing
    
    Hook Tests:
    - useDirectorySettings.test.tsx (32 lines):
      * Updated for refactored hook logic
      * Enhanced test coverage for edge cases
    
    - useDragSort.test.tsx (36 lines):
      * Simplified test cases
      * Better mock implementation
      * Improved assertions
    
    - useImportExport tests (16 lines total):
      * Updated for new error handling
      * Enhanced test coverage
    
    - useMcpValidation.test.tsx (23 lines):
      * Updated validation test cases
      * Better coverage of error scenarios
    
    - useProviderActions.test.tsx (48 lines):
      * Extensive updates for hook refactoring
      * New test cases for provider operations
      * Enhanced mock data
    
    - useSettings.test.tsx (12 lines):
      * New test cases for auto-launch
      * Enhanced settings state testing
      * Better async operation coverage
    
    Integration Tests:
    - App.test.tsx (41 lines):
      * Updated for new routing logic
      * Enhanced navigation testing
      * Better component integration coverage
    
    - SettingsDialog.test.tsx (88 lines):
      * Complete rewrite for SettingsPage
      * New integration test scenarios
      * Enhanced user workflow testing
    
    Mock Infrastructure:
    - handlers.ts (117 lines):
      * Major updates for MSW handlers
      * New handlers for auto-launch commands
      * Enhanced error simulation
      * Better request/response mocking
    
    - state.ts (37 lines):
      * Updated mock state structure
      * New state for auto-launch
      * Enhanced state reset functionality
    
    - tauriMocks.ts (10 lines):
      * Updated mock implementations
      * Better type safety
    
    - server.ts & testQueryClient.ts:
      * Minor cleanup (2 lines removed)
    
    Test Infrastructure Improvements:
    - Better test isolation
    - Enhanced mock data consistency
    - Improved async operation testing
    - Better error scenario coverage
    - Enhanced integration test patterns
    
    Coverage Improvements:
    - Net increase of 195 lines of test code
    - Better coverage of edge cases
    - Enhanced error path testing
    - Improved integration test scenarios
    - Better mock infrastructure
    
    All tests now pass with the refactored components while maintaining
    comprehensive coverage of functionality and edge cases.
  • test: add error handling and edge case tests for hooks
    useSettings Tests:
    - Add test for null settings state protection
      - Returns null immediately without calling APIs
      - Prevents null pointer errors in save flow
    - Add test for save mutation failure
      - Verifies error propagates to caller
      - Ensures restart flag remains untouched on failure
      - Validates no side effects when save fails
    
    useProviderActions Tests:
    - Add error propagation tests for CRUD operations
      - updateProvider: propagates errors to caller
      - addProvider: propagates errors to caller
      - deleteProvider: propagates errors to caller
    - Add switch mutation error handling tests
      - Claude switch: handles errors silently (no throw)
      - Codex switch: skips plugin sync when mutation fails
      - Verifies plugin sync APIs not called on failure
    - Add loading state verification
      - Test all mutations pending scenario (existing)
      - Test all mutations idle scenario (new)
      - Ensures isLoading flag accuracy
    
    useImportExport Edge Case Tests (new file):
    - Add test for user cancelling file dialog
      - File dialog returns null (user cancelled)
      - State remains unchanged (selectedFile: "", status: "idle")
      - No error toast shown
    - Add test for resetStatus behavior
      - Clears error message and status
      - Preserves selected file path for retry
      - Resets backupId to null
    
    All tests passing: 79/79 (10 new tests)
  • test: add useProviderActions hook unit tests
    - Add comprehensive tests for provider CRUD operations:
      * addProvider: trigger mutation correctly
      * updateProvider: update provider and refresh tray menu
      * deleteProvider: call delete mutation
      * isLoading: track all mutation pending states
    - Test Claude plugin integration sync logic:
      * Conditional sync based on app type (claude vs codex)
      * Integration toggle handling (enabled/disabled)
      * Error handling with custom/fallback messages
      * Official vs custom provider category detection
    - Test usage script save functionality:
      * Update provider meta and invalidate cache on success
      * Display error toast with custom/fallback messages on failure
    - Mock React Query mutations, Tauri API, and toast notifications
    - Fix TypeScript spread operator issues in mock definitions
    - Cover all success/failure paths and edge cases
    
    Test Coverage:
      ✓ 12 test cases covering provider actions
      ✓ Plugin sync: 5 scenarios (app type, toggle, errors)
      ✓ CRUD operations: add, update, delete
      ✓ Usage script: save success/failure
      ✓ Estimated 95%+ code coverage
    
    Related: Provider management, Claude plugin integration, usage scripts
    Total Tests: 16 passed (4 useDragSort + 12 useProviderActions)