Repository navigation
test: add snapshotEnv helper and close env and auth cleanup gaps (TA-001 slice 4) - #2335
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
jatmn
left a comment
There was a problem hiding this comment.
— jatmn's PR Review agent
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
Summary
src/test/envSnapshot.ts:snapshotEnv(keys, { clear? })saves the named variables, can optionally unset them, and returns a restore function. Restore puts back the exact previous values (including empty strings) and deletes the ones that were unset. It is not a blanket scrub. Covered bysrc/test/envSnapshot.test.ts.src/utils/providerFlag.test.ts:CLAUDE_CODE_PROVIDER_ROUTE_ID(set tocommandcodein one test) was missing from the hand-maintained snapshot/restore lists and leaked out of the file. The lists are replaced with the helper, and the route id is included.src/services/api/openaiShim.ollamaTextToolCalls.test.tsandsrc/services/api/openaiShim/xmlToolCallParsing.test.ts: cleanup deleted provider keys instead of restoring whatever was set before. They now use the helper.src/utils/fastMode.test.tsandsrc/hooks/useApiKeyVerification.test.tsx: cleanup re-registered the liveutils/authnamespace, which Bun had already redirected to the mock, so the auth stubs leaked into later files (follow-up noted in test: isolate attribution suites from leaked auth, beta and routing mocks (TA-001 slice 5) #2334). Both now restore from a real-module snapshot copied before any mock is registered, the same pattern as earlier TA-001 slices.CONTRIBUTING.md: one test-guidance bullet on usingsnapshotEnv.Impact
betasandcompacttests' intentional clears are unchanged.--isolatestays in CI and is handled by the next slice.Testing
bun run build, temp config dirs):bun run typecheck: pass.bun run check: pass, including all 8--isolateshards.bun test(no--isolate): 10434 pass, 31 skip, 0 fail across 782 files.gitSettings.test.tstests ("omits git instructions outside a git repository" and "follows the session cwd"). On the build host, a sandboxed tool outside this repo briefly creates an empty.gitdirectory in the system temp dir, and that run overlapped one. The file passes on its own (8/8) and in the full rerun above, so the failures were environmental and unrelated to this diff.Notes
--isolateis the next slice.Summary by CodeRabbit