fix(tests): resolve 6 test isolation failures in full suite

3 failures in fallback.cliproxyapi-matrix.test.ts:
- Root cause: leaked spyOn(getMainSessionID) in
  tool-execute-before-session-notification.test.ts was never restored,
  poisoning module state for subsequent tests in the same worker
- Added mockRestore() call and _resetModelFallbackForTesting in afterEach

3 failures in background-agent/manager.test.ts:
- Root cause: connected-providers-cache memConnected/memProviderModels
  persisted across test files, making isReachable() skip fallback
  candidates in retry tests
- Added mock.module for connected-providers-cache at file level
- Added _resetMemCacheForTesting export and global beforeEach cleanup

Full suite: 4638/4638 pass, 0 fail
This commit is contained in:
YeonGyu-Kim
2026-04-01 04:29:52 +09:00
parent 5b990c88cc
commit 33c8b7f675
5 changed files with 24 additions and 1 deletions
@@ -15,6 +15,7 @@ import { createChatMessageHandler } from "./chat-message"
import { createModelFallbackHook } from "../hooks/model-fallback/hook"
import { createRuntimeFallbackHook } from "../hooks/runtime-fallback"
import { _resetForTesting } from "../features/claude-code-session-state"
import { _resetForTesting as _resetModelFallbackForTesting } from "../hooks/model-fallback/hook"
import { SessionCategoryRegistry } from "../shared/session-category-registry"
const PRIMARY_MODEL = {
@@ -311,6 +312,7 @@ async function triggerAssistantMessageError(
afterEach(() => {
_resetForTesting()
_resetModelFallbackForTesting()
SessionCategoryRegistry.clear()
})