test(voice): extract the duplicated PassingJudge test double to fixtures/#797
Conversation
PassingJudge (a fake judge that concludes a voice run successfully on the judge() step) was copied across four voice suites in two slightly diverging variants. fixtures/ is already the home for shared voice test doubles (FakeVoiceAdapter, AudioUserSimulator), so hoist a single PassingJudge there and drop the copies. No suite asserts on the judge's criteria or reasoning text (only result.success), so one canonical version is safe. Closes #786. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Automated low-risk assessment This PR was evaluated against the repository's Low-Risk Pull Requests procedure.
An approving review has been submitted by automation. The PR may merge once required CI checks pass. |
WalkthroughChangesThe duplicated Voice test fixture extraction
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
langwatch-agent
left a comment
There was a problem hiding this comment.
No findings. I checked #786 against the current tree: the remaining duplicated PassingJudge copies under javascript/src are gone, the new shared fixture preserves the successful judge behavior the affected suites assert on, and voice-spans-stt.test.ts does not currently contain a copy to migrate.
Validation run locally from the existing PR worktree:
npx vitest run javascript/src/voice/__tests__/duration-fidelity.test.ts javascript/src/voice/__tests__/interrupt-truncation.test.ts javascript/src/voice/__tests__/proceed-interrupt.test.ts javascript/src/voice/__tests__/result-audio.test.ts— 22 tests passed.npm run typecheckfromjavascript/— passed.npx eslint src/voice/__tests__/fixtures/passing-judge.ts— passed.
CI still had the aggregate JavaScript check and CodeRabbit pending when I checked, so this review is based on the completed local validation plus the changed surface.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
javascript/src/voice/__tests__/fixtures/passing-judge.ts (1)
9-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider making
criteriareadonly.The
criteriaproperty is only read (spread intometCriteria), never reassigned. Marking itreadonlyaligns with the guideline to use readonly properties where appropriate and prevents accidental mutation.♻️ Proposed refactor
- criteria: string[] = ["Agent responds"]; + readonly criteria: string[] = ["Agent responds"];🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@javascript/src/voice/__tests__/fixtures/passing-judge.ts` at line 9, Mark the criteria property in the passing-judge fixture as readonly while preserving its existing string-array value and read-only usage.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@javascript/src/voice/__tests__/fixtures/passing-judge.ts`:
- Line 9: Mark the criteria property in the passing-judge fixture as readonly
while preserving its existing string-array value and read-only usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: df788318-1d62-4c73-9c91-516d4acfe007
📒 Files selected for processing (5)
javascript/src/voice/__tests__/duration-fidelity.test.tsjavascript/src/voice/__tests__/fixtures/passing-judge.tsjavascript/src/voice/__tests__/interrupt-truncation.test.tsjavascript/src/voice/__tests__/proceed-interrupt.test.tsjavascript/src/voice/__tests__/result-audio.test.ts
Ticket
Closes #786. Follow-up from the #783 review:
PassingJudge(a fake judge that concludes a run successfully on thejudge()step) was copied across several voice suites.javascript/src/voice/__tests__/fixtures/is already the home for shared voice test doubles (FakeVoiceAdapter,AudioUserSimulator).Change
fixtures/passing-judge.tsexporting a singlePassingJudge.duration-fidelity,interrupt-truncation,proceed-interrupt, andresult-audioand imported the shared one (also dropped the now-unusedJudgeAgentAdapterimport from each).The four copies had drifted into two variants (
["Agent responds"]/ "voice turn completed" vs["ok"]/ "done"). No suite asserts on the judge'scriteria,reasoning, ormetCriteria(onlyresult.success === true), so consolidating to one canonical version is behavior-preserving.proceed-interrupt's judge-timing rationale comment is kept, relocated to the usage site.Note:
voice-spans-stt.test.ts(named in the issue) has noPassingJudgecopy onmain, so nothing to change there.Evidence
npx vitest runon the four suites: 22 passed.pnpm typecheckclean.import/ordererrors in these test files are unrelated to this change and are not gated by CI:lint:allskips the root package andlint:libexcludes*.test.ts/__tests__/**.)Advisory note
Advisory PR from the tech-debt-fixer bot, for human review, not to be merged by the bot.