Commit Graph

1 Commits

  • test: add useDirectorySettings and useSettingsMetadata hook tests
    useDirectorySettings Tests:
    - Test directory initialization with overrides and remote defaults
      - Verify app config override with space trimming
      - Load Claude/Codex directories from remote API
      - Calculate resolvedDirs correctly
    - Test directory browsing functionality
      - Browse Claude/Codex config directories
      - Browse app config directory with proper default paths
      - Update settings callback when selection succeeds
    - Test error handling scenarios
      - User cancels directory selection (returns null)
      - Directory picker throws error (shows toast)
      - Verify settings not updated on failure
    - Test directory reset operations
      - Reset individual directories to computed defaults
      - Reset app config directory
      - Batch reset with provided server values
    - Use vi.hoisted() for proper mock initialization
    - Factory function for settings creation (reusability)
    
    useSettingsMetadata Tests:
    - Test portable mode flag loading
      - Verify initial loading state
      - Load portable flag from API
      - Handle async state transitions
    - Test error tolerance when API fails
      - Silent failure on network errors
      - Default to non-portable mode
      - Continue without blocking UI
    - Test restart flag management
      - Set restart required flag
      - Acknowledge restart to clear flag
      - State updates wrapped in act()
    
    All tests passing: 10/10 (7 useDirectorySettings + 3 useSettingsMetadata)