This project uses a comprehensive testing strategy to prevent regressions and ensure reliable functionality across UI and backend components.
- Location:
src/__tests__/unit/ - Purpose: Test individual components, store logic, and utilities
- Key Focus: State management, preference persistence, navigation logic
- Location:
e2e/ - Purpose: Test complete user workflows and integration
- Key Focus: User interactions, cross-session persistence, regression prevention
# Run tests in watch mode (development)
npm test
# Run tests once
npm run test:run
# Open Vitest UI
npm run test:ui# Run E2E tests (requires app to be running)
npm run test:e2e
# Open Playwright test UI
npm run test:e2e-uiThese tests specifically target the issues mentioned in the initial requirements:
-
Hidden Files Toggle (
src/__tests__/unit/store/useAppStore.test.ts)- Tests global and directory-specific preference persistence
- Verifies state synchronization with native menus
- Ensures preferences survive navigation
-
Directory Persistence (E2E tests in
e2e/preferences.spec.ts)- Tests that the app reopens to the last visited directory
- Verifies directory-specific preferences are maintained
- Tests rapid state changes don't corrupt data
-
Navigation State (E2E tests in
e2e/navigation.spec.ts)- Tests history management across sessions
- Verifies keyboard shortcuts work correctly
- Tests path editing and validation
toggleHiddenFiles()- Critical for hidden file regression preventionupdateDirectoryPreferences()- Ensures per-directory settings persistnavigateTo()- Tests navigation history and state management- Preference persistence across app restarts
describe('useAppStore', () => {
describe('toggleHiddenFiles', () => {
it('should toggle global hidden files preference', async () => {
// Test implementation
});
});
});test('should toggle hidden files and persist across navigation', async ({ page }) => {
// Full user workflow test
});- Mock
@tauri-apps/api/coreinvoke function - Mock
@tauri-apps/plugin-dialogfor UI interactions - Mock filesystem operations with predictable responses
- Run against actual Tauri dev server
- Test real user interactions with browser automation
- Verify persistent state across page reloads
- Add unit tests for state management logic
- Add component tests for UI behavior
- Add E2E tests for complete user workflows
- Write a failing test that reproduces the bug
- Fix the bug
- Verify the test passes
- Add regression test to prevent future occurrences
Tests are configured to run automatically:
- Unit tests run on file changes during development
- All tests should pass before creating pull requests
- E2E tests verify the complete application works end-to-end
- Unit tests are fast and run frequently
- E2E tests are slower but provide comprehensive coverage
- Tests focus on critical user paths and known regression areas
- Mock heavy operations to keep tests fast and reliable