150 lines
3.3 KiB
Markdown
150 lines
3.3 KiB
Markdown
|
|
# Voice to Notes — Testing Strategy
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
Each layer has its own test approach. Agents should run tests after every significant change before considering work complete.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 1. Rust Backend Tests
|
||
|
|
|
||
|
|
**Tool:** `cargo test` (built-in)
|
||
|
|
**Location:** `src-tauri/src/` (inline `#[cfg(test)]` modules)
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd src-tauri && cargo test
|
||
|
|
```
|
||
|
|
|
||
|
|
**What to test:**
|
||
|
|
- SQLite schema creation and migrations
|
||
|
|
- Database CRUD operations (projects, media files, segments, words, speakers)
|
||
|
|
- IPC message serialization/deserialization (serde)
|
||
|
|
- llama-server port allocation logic
|
||
|
|
- File path handling across platforms
|
||
|
|
|
||
|
|
**Lint/format check:**
|
||
|
|
```bash
|
||
|
|
cd src-tauri && cargo fmt --check && cargo clippy -- -D warnings
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Python Sidecar Tests
|
||
|
|
|
||
|
|
**Tool:** `pytest`
|
||
|
|
**Location:** `python/tests/`
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd python && python -m pytest tests/ -v
|
||
|
|
```
|
||
|
|
|
||
|
|
**What to test:**
|
||
|
|
- IPC protocol: JSON-line encode/decode, message routing
|
||
|
|
- Transcription service (mock faster-whisper for unit tests)
|
||
|
|
- Diarization service (mock pyannote for unit tests)
|
||
|
|
- AI provider adapters (mock HTTP responses)
|
||
|
|
- Export formatters (SRT, WebVTT, text output correctness)
|
||
|
|
- Hardware detection logic
|
||
|
|
|
||
|
|
**Lint check:**
|
||
|
|
```bash
|
||
|
|
cd python && ruff check . && ruff format --check .
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Frontend Tests
|
||
|
|
|
||
|
|
**Tool:** `vitest` (Vite-native, works with Svelte)
|
||
|
|
**Location:** `src/lib/**/*.test.ts`
|
||
|
|
|
||
|
|
```bash
|
||
|
|
npm run test
|
||
|
|
```
|
||
|
|
|
||
|
|
**What to test:**
|
||
|
|
- Svelte store logic (transcript, playback, project state)
|
||
|
|
- Tauri bridge service (mock tauri::invoke)
|
||
|
|
- Audio sync calculations (timestamp → word mapping)
|
||
|
|
- Export option formatting
|
||
|
|
|
||
|
|
**Lint/format check:**
|
||
|
|
```bash
|
||
|
|
npm run check # svelte-check (TypeScript)
|
||
|
|
npm run lint # eslint
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Integration Tests
|
||
|
|
|
||
|
|
### IPC Round-trip Test
|
||
|
|
Verify Rust ↔ Python communication works end-to-end:
|
||
|
|
```bash
|
||
|
|
# From project root
|
||
|
|
cd src-tauri && cargo test --test ipc_integration
|
||
|
|
```
|
||
|
|
This spawns the real Python sidecar, sends a ping message, and verifies the response.
|
||
|
|
|
||
|
|
### Tauri App Launch Test
|
||
|
|
Verify the app starts and the frontend loads:
|
||
|
|
```bash
|
||
|
|
cd src-tauri && cargo test --test app_launch
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 5. Quick Validation Script
|
||
|
|
|
||
|
|
Agents should run this after any significant change:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
#!/bin/bash
|
||
|
|
# scripts/validate.sh — Run all checks
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "=== Rust checks ==="
|
||
|
|
cd src-tauri
|
||
|
|
cargo fmt --check
|
||
|
|
cargo clippy -- -D warnings
|
||
|
|
cargo test
|
||
|
|
cd ..
|
||
|
|
|
||
|
|
echo "=== Python checks ==="
|
||
|
|
cd python
|
||
|
|
ruff check .
|
||
|
|
ruff format --check .
|
||
|
|
python -m pytest tests/ -v
|
||
|
|
cd ..
|
||
|
|
|
||
|
|
echo "=== Frontend checks ==="
|
||
|
|
npm run check
|
||
|
|
npm run lint
|
||
|
|
npm run test -- --run
|
||
|
|
|
||
|
|
echo "=== All checks passed ==="
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 6. Manual Testing (Final User Test)
|
||
|
|
|
||
|
|
These require a human to verify since they involve audio playback and visual UI:
|
||
|
|
- Import a real audio file and run transcription
|
||
|
|
- Verify waveform displays correctly
|
||
|
|
- Click words → audio seeks to correct position
|
||
|
|
- Rename speakers → changes propagate
|
||
|
|
- Export caption files → open in VLC/subtitle editor
|
||
|
|
- AI chat → get responses about transcript content
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 7. Test Fixtures
|
||
|
|
|
||
|
|
Store small test fixtures in `tests/fixtures/`:
|
||
|
|
- `short_clip.wav` — 5-second audio clip with 2 speakers (for integration tests)
|
||
|
|
- `sample_transcript.json` — Pre-built transcript data for UI/export tests
|
||
|
|
- `sample_ipc_messages.jsonl` — Example IPC message sequences
|
||
|
|
|
||
|
|
Agents should create mock/fixture data rather than requiring real audio files for unit tests.
|