This project uses Vitest (jsdom environment) and @testing-library/svelte.
npm run test
npm run test:watch
npm run checksrc/lib/protocol/types.test.ts- envelope constructor correctness
src/lib/protocol/e2e.test.ts- key generation
- shared-key derivation
- encrypt/decrypt roundtrip
- decrypt failure with wrong key
src/lib/protocol/client.test.ts- connect/pair/send flows
pairing_result,assistant_finalhandling- E2E decrypt path for
assistant_chunk - reconnect/backoff behavior
- guards against duplicate connect and send-on-closed-socket
src/lib/stores/session.test.ts- streaming chunk/final behavior
- legacy content fallback
- tool/approval correlation
- error handling
src/lib/session/auth-storage.test.ts- save/load/clear flows
- malformed/expired payload cleanup
src/lib/session/connection-controller.test.ts- session restore
- local send-error behavior
src/lib/components/PairingScreen.test.ts- PIN sanitization
- submit validation
src/lib/components/StatusBar.test.ts- endpoint/session rendering
- theme/effects/logout callbacks
src/lib/theme.test.ts,src/lib/ui/preferences.test.ts- theme/effects persistence and body class behavior
- One test should assert one behavioral guarantee.
- Prefer observable behavior over private implementation details.
- Use mocked WebSocket for transport tests.
- Use in-memory mocked
Storagefor persistence tests. - Use user-level interactions for component tests.
- Component tests for:
ChatScreenMessageBubbleToolCallBlockApprovalPrompt
- Full flow integration smoke test: pairing -> chatting.
- Optional browser E2E coverage (for example with Playwright + mock backend).
npm run testnpm run check- Manual smoke:
- successful pairing
- send message
- error handling
- logout and reconnect