fix(ci): resolve mock.module() cross-file leakage in test suite

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-04 02:35:23 +09:00
parent 673b107f53
commit 6acca09bd0
15 changed files with 130 additions and 66 deletions
@@ -6,9 +6,11 @@ mock.module("../../shared", () => ({
log: logMock,
}))
import { abortWithTimeout } from "./abort-with-timeout"
import type { OpencodeClient } from "./opencode-client"
const { abortWithTimeout } = await import("./abort-with-timeout")
mock.restore()
function createClient(abort: (...args: Array<unknown>) => Promise<unknown>): OpencodeClient {
return {
session: {
@@ -17,14 +17,15 @@ mock.module("../../shared/provider-model-id-transform", () => ({
transformModelForProvider: mock((_provider: string, model: string) => model),
}))
import { tryFallbackRetry } from "./fallback-retry-handler"
import { shouldRetryError } from "../../shared/model-error-classifier"
import { selectFallbackProvider } from "../../shared/model-error-classifier"
import { readProviderModelsCache } from "../../shared"
import type { BackgroundTask } from "./types"
import type { ConcurrencyManager } from "./concurrency"
import type { OpencodeClient, QueueItem } from "./constants"
const { tryFallbackRetry } = await import("./fallback-retry-handler")
const { shouldRetryError, selectFallbackProvider } = await import("../../shared/model-error-classifier")
const { readProviderModelsCache } = await import("../../shared")
mock.restore()
function createDeferredPromise(): {
promise: Promise<void>
resolve: () => void
@@ -20,6 +20,7 @@ import { MIN_IDLE_TIME_MS } from "./constants"
import { BackgroundManager } from "./manager"
import { ConcurrencyManager } from "./concurrency"
import { initTaskToastManager, _resetTaskToastManagerForTesting } from "../task-toast-manager/manager"
mock.restore()
const TASK_TTL_MS = 30 * 60 * 1000
@@ -1,11 +1,13 @@
import { describe, test, expect, mock, afterAll } from "bun:test"
import { isActiveSessionStatus, isTerminalSessionStatus } from "./session-status-classifier"
const mockLog = mock()
mock.module("../../shared", () => ({ log: mockLog }))
afterAll(() => { mock.restore() })
const { isActiveSessionStatus, isTerminalSessionStatus } = await import("./session-status-classifier")
mock.restore()
describe("isActiveSessionStatus", () => {
describe("#given a known active session status", () => {
test('#when type is "busy" #then returns true', () => {