Desktop App for Terraphim AI Assistant

This is a Tauri-based desktop application with Svelte frontend for the Terraphim AI assistant.

Architecture

  • Backend: Rust with Tauri for system integration, search, and configuration
  • Frontend: Svelte with Bulma CSS for the user interface
  • Features: System tray, global shortcuts, multi-theme support, typeahead search

Development

To run in development mode:

yarn install        # install dependencies
yarn run dev       # run the Svelte dev server
yarn run tauri dev # run the Tauri dev server

Testing

We have implemented a comprehensive testing strategy covering multiple aspects:

Backend Tests (Rust)

cd src-tauri
cargo test --verbose

Tests include:

  • Unit tests for Tauri commands (search, config, thesaurus)
  • Integration tests for state management
  • Error handling and edge cases
  • Async functionality testing

Frontend Tests (Svelte)

yarn test           # Run unit tests
yarn test:watch     # Run tests in watch mode
yarn test:coverage  # Run tests with coverage
yarn test:ui        # Run tests with UI

Tests include:

  • Component tests for Search, ThemeSwitcher, etc.
  • Store and state management tests
  • User interaction tests
  • Mock Tauri API integration

End-to-End Tests

yarn e2e           # Run E2E tests
yarn e2e:ui        # Run E2E tests with UI

Tests include:

  • Complete user workflows
  • Search functionality
  • Navigation and routing
  • Theme switching
  • Error handling

Visual Regression Tests

npx playwright test tests/visual

Tests include:

  • Theme consistency across all 22 themes
  • Responsive design testing
  • Component visual consistency
  • Accessibility visual checks

Performance Tests

# Requires Lighthouse CI
npm install -g @lhci/cli
yarn build
lhci autorun

Test Structure

desktop/
β”œβ”€β”€ src-tauri/
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── cmd_tests.rs        # Backend unit tests
β”‚   └── src/
β”‚       β”œβ”€β”€ cmd.rs              # Commands with test coverage
β”‚       └── lib.rs              # Exposed for testing
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ Search/
β”‚   β”‚   β”‚   └── Search.test.ts  # Search component tests
β”‚   β”‚   └── ThemeSwitcher.test.ts # Theme tests
β”‚   └── test-utils/
β”‚       └── setup.ts            # Test configuration
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ e2e/
β”‚   β”‚   β”œβ”€β”€ search.spec.ts      # E2E search tests
β”‚   β”‚   └── navigation.spec.ts   # E2E navigation tests
β”‚   β”œβ”€β”€ visual/
β”‚   β”‚   └── themes.spec.ts      # Visual regression tests
β”‚   β”œβ”€β”€ global-setup.ts         # Test data setup
β”‚   └── global-teardown.ts      # Test cleanup
β”œβ”€β”€ vitest.config.ts            # Frontend test config
└── playwright.config.ts       # E2E test config

Testing Best Practices

  1. Isolation: Each test is independent and can run in any order
  2. Mocking: External dependencies are properly mocked
  3. Coverage: Aim for >80% code coverage
  4. Performance: Tests run efficiently in CI/CD
  5. Reliability: Tests are stable and don't have flaky behavior

Continuous Integration

Tests run automatically on:

  • Push to main/develop branches
  • Pull requests
  • Multiple platforms (Ubuntu, macOS, Windows)

Test results include:

  • Unit test results and coverage
  • E2E test results with screenshots/videos
  • Visual regression differences
  • Performance metrics
  • Security audit results

Production

To build for production:

yarn install      # install dependencies
yarn run build    # build the Svelte app
yarn run tauri build # build the Tauri app

Testing Coverage Goals

  • Backend: >90% coverage for business logic
  • Frontend: >85% coverage for components and stores
  • E2E: Cover all major user workflows
  • Visual: Test all themes and responsive breakpoints
  • Performance: Maintain Lighthouse scores >80

Running All Tests

To run the complete test suite:

# Install dependencies
yarn install

# Run all tests
yarn test           # Frontend unit tests
cd src-tauri && cargo test && cd .. # Backend tests
yarn e2e            # E2E tests
npx playwright test tests/visual    # Visual tests