[codex] test(desktop): isolate host-service coordinator mocks#4448
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTest file ChangesTest Setup Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ 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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Greptile SummaryThis PR tightens mock isolation in the host-service coordinator test suite to prevent Bun's process-global mock registry from leaking partial module exports into unrelated desktop tests. The approach is correct: real module exports are captured with top-level
Confidence Score: 5/5Test-only change with no production code impact; mock isolation patterns are applied correctly. All changes are confined to a single test file. The partial-mock pattern (capture real exports then spread then override) is idiomatic for Bun and correct here. The mock.restore() in afterAll fires after all tests in the file complete, so it cannot interfere with any in-file test assertions. The removed mocks are confirmed unused by the PR author's validation run, and the test logic itself is unchanged. No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/lib/host-service-coordinator.test.ts | Mock isolation improvements: partial mocks now spread real exports, unused broad mocks removed, and afterAll restores Bun's mock registry — all changes are correct and test-only. |
Reviews (1): Last reviewed commit: "test(desktop): isolate host-service coor..." | Re-trigger Greptile
Summary
Follow-up to #4395. The host-service coordinator test used broad Bun
mock.modulereplacements that leaked through Bun's process-global mock registry into unrelated desktop tests.This narrows the mocks by preserving real exports for partially mocked modules, removes unused broad mocks, and restores Bun mocks in
afterAll.Impact
Desktop tests can run in the same Bun process without unrelated modules observing incomplete mock exports or test-only environment values.
Validation
bun test apps/desktop/src/main/lib/host-service-coordinator.test.tsbunx biome check apps/desktop/src/main/lib/host-service-coordinator.test.tsbun run lint:fixbun run lintSummary by cubic
Isolated and cleaned up Bun mocks in the host-service coordinator tests to stop leaking partial module exports and test-only env into other desktop tests. Partially mock only what’s needed and restore mocks after the suite.
./host-service-manifest,./host-service-utils, and@superset/shared/host-info.main/env.main,shared/env.shared,./app-environment,./terminal/env, and../../lib/trpc/routers/workspaces/utils/shell-env.afterAllviamock.restore().Written for commit 64c5c95. Summary will update on new commits.
Summary by CodeRabbit