Repository navigation
fix(test): isolate buildClaudeCommand tests from host ~/.genie/config.json - #1171
Conversation
….json Two tests in src/genie-commands/__tests__/session.test.ts — "with system prompt file references it via --append-system-prompt-file" and "file path is passed directly, no content inlined" — implicitly assumed the host machine's ~/.genie/config.json had promptMode unset or "append". On any machine with promptMode: "system", buildTeamLeadCommand emits --system-prompt-file instead, causing the assertions to fail. The fragility was previously masked by the leaking mock.module in init-*.test.ts that PR #1169 replaced with spyOn. Removing the leak unmasked this latent weakness. Fix: mirror PR #1169's spyOn pattern in the buildClaudeCommand describe block — spy on genie-config.loadGenieConfigSync in beforeEach and mockRestore in afterEach, pinning promptMode: "append" for the suite. Production code in team-lead-command.ts is untouched; this is a test-only hygiene fix. Closes the tail surfaced during PR #1169 QA — tests no longer depend on host ~/.genie/config.json. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Code Review
This pull request updates the session.test.ts file to stabilize tests by mocking the loadGenieConfigSync function. By using spyOn to pin the promptMode to 'append', the tests are now independent of the host's local configuration and avoid mock leakage issues associated with mock.module in Bun. I have no feedback to provide as no issues were identified.
…-robustness fix(test): isolate buildClaudeCommand tests from host ~/.genie/config.json
Summary
Two tests in
src/genie-commands/__tests__/session.test.ts—buildClaudeCommand > with system prompt file references it via --append-system-prompt-fileandbuildClaudeCommand > file path is passed directly, no content inlined— implicitly assumed the host machine's~/.genie/config.jsonhadpromptModeunset or"append". On any host configured withpromptMode: "system",buildTeamLeadCommandemits--system-prompt-fileinstead, and the assertions fail.This fragility was previously masked by the leaking
mock.module('../lib/genie-config.js', ...)frominit-*.test.tsthat PR #1169 replaced withspyOn. Removing the leak unmasked this latent weakness.Closes the tail surfaced during PR #1169 QA — tests no longer depend on host ~/.genie/config.json.
Fix
Mirror PR #1169's
spyOnpattern inside thebuildClaudeCommanddescribeblock:* as genieConfig from '../../lib/genie-config.js'spyOn(genieConfig, 'loadGenieConfigSync').mockReturnValue({ promptMode: 'append' })inbeforeEachloadGenieConfigSyncSpy.mockRestore()inafterEachScope: 1 file touched (
src/genie-commands/__tests__/session.test.ts). Production code insrc/lib/team-lead-command.tsis untouched — this is a test-only hygiene fix.BEFORE / AFTER reproducer
BEFORE (on
origin/dev, host~/.genie/config.jsonhaspromptMode: "system")AFTER (this branch, both host scenarios)
Full suite
Test plan
origin/devwith hostpromptMode: "system"(29/2)promptMode: "system"bun run check— 2501/0🤖 Generated with Claude Code