Skip to content

Add Vitest harness and characterization tests for voice surface - #6

Merged
m9h merged 1 commit into
devfrom
tests/voice-baseline
May 8, 2026
Merged

Add Vitest harness and characterization tests for voice surface#6
m9h merged 1 commit into
devfrom
tests/voice-baseline

Conversation

@m9h

@m9h m9h commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Sets up the test infrastructure (Vitest, React Testing Library, MSW, happy-dom) the project was missing
  • Adds 31 tests across 5 files covering the voice features Lilian shipped without test coverage
  • Adds GitHub Actions workflow that runs `npm run test:ci` on push/PR to `main` and `dev`

From here forward, new code on this project follows red-green TDD; this commit is characterization-only (locks in current behavior so future changes can't silently regress).

Coverage

File Cases What it covers
`src/lib/speech.test.ts` 8 `chunkBySentence` — empty, single, multi, terminator runs, fragments, abbreviations, whitespace, quoted speech
`src/app/api/tts/route.test.ts` 9 Polly client mocked; creds guard, text guard, voice allowlist fallback, 3000-char truncation, audio response shape, no AudioStream → 502, Polly throws → 500
`src/app/api/stt/route.test.ts` 7 Google STT fetch mocked; key guard, audio guard, single + multi result join, empty results, error pass-through, request shape contract
`src/hooks/useSpeechOutput.test.tsx` 3 Regression for the wrong-Polly-voice bug — voiceId param wins over default, fallback to default, ref tracks latest default after re-render
`src/app/api/chat/route.test.ts` 4 Regression for the Gemini 503 retry — succeeds after 1 retry, gives up after 3, no retry on 4xx, no retry on 200

Deferred (follow-up PR)

  • Show-button reveal / disable while speaking — easier as Playwright spec
  • `useSpeechInput` hook — heavy MediaRecorder/AudioContext mocking, low ROI vs E2E
  • `MicButton`, `VoiceBubble` snapshot tests

Test plan

  • `npm run test:ci` — 31/31 passing locally
  • `npx tsc --noEmit` — clean
  • CI passes on this PR
  • Verify CI runs on subsequent push to this branch (it should re-run because the PR already exists)

🤖 Generated with Claude Code

Sets up the test infrastructure (Vitest, React Testing Library, MSW,
happy-dom) and locks in current behavior of the voice features Lilian
shipped without tests. From here forward, new code on this project
follows red-green TDD; this commit is characterization-only.

Coverage:
- src/lib/speech.test.ts — chunkBySentence sentence splitting (8 cases)
- src/app/api/tts/route.test.ts — Polly client, voice allowlist, text
  truncation, audio response, error paths (9 cases)
- src/app/api/stt/route.test.ts — Google STT request shape, transcript
  joining, error propagation (7 cases)
- src/hooks/useSpeechOutput.test.tsx — regression: voiceId param
  overrides defaultVoice (the bug Lilian fixed where the stage opener
  used the wrong Polly voice because React state hadn't propagated)
  (3 cases)
- src/app/api/chat/route.test.ts — regression: 503 retry with backoff,
  no retry on non-503, no retry on success (4 cases)

CI runs npm run test:ci on push and PR to main/dev.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
thinking-higher Ready Ready Preview, Comment May 7, 2026 1:44am

@m9h
m9h merged commit 56712e5 into dev May 8, 2026
3 checks passed
@m9h
m9h deleted the tests/voice-baseline branch May 8, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant