test: add SettingsDialog integration tests and enhance MSW infrastructure

- Add comprehensive SettingsDialog integration tests with 3 test cases:
  * Load default settings from MSW
  * Import configuration and trigger success callback
  * Save settings and handle restart prompt
- Extend MSW handlers with settings-related endpoints:
  * get_settings/save_settings for settings management
  * app_config_dir_override for custom config directory
  * apply_claude_plugin_config for plugin integration
  * import/export config file operations
  * file/directory dialog mocks
- Add settings state management to MSW mock state:
  * Settings state with default values
  * appConfigDirOverride state
  * Reset logic in resetProviderState()
- Mock @tauri-apps/api/path for DirectorySettings tests
- Refactor App.test.tsx to focus on happy path scenarios:
  * Remove delete functionality test (covered in useProviderActions unit tests)
  * Reorganize test flow: settings → switch → usage → create → edit → switch → duplicate
  * Remove unnecessary state verifications
  * Simplify event testing

All tests passing: 4 integration tests + 12 unit tests
This commit is contained in:
Jason
2025-10-25 19:59:31 +08:00
parent 96a8712f2d
commit 001ac14c85
5 changed files with 291 additions and 30 deletions

View File

@@ -59,3 +59,7 @@ vi.mock("@tauri-apps/api/event", () => ({
// Ensure the MSW server is referenced so tree shaking doesn't remove imports
void server;
vi.mock("@tauri-apps/api/path", () => ({
homeDir: async () => "/home/mock",
join: async (...segments: string[]) => segments.join("/"),
}));