test(auto-compact): restore module mocks after hook test

Prevent cross-file mock.module leakage by restoring Bun mocks after recovery-hook test, so executor tests always run against the real module implementation.
This commit is contained in:
YeonGyu-Kim
2026-02-21 03:57:21 +09:00
parent d618678844
commit fbe7e61ab4

View File

@@ -1,4 +1,4 @@
import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test"
import { afterAll, afterEach, beforeEach, describe, expect, mock, test } from "bun:test"
import type { PluginInput } from "@opencode-ai/plugin"
import * as originalExecutor from "./executor"
import * as originalParser from "./parser"
@@ -81,6 +81,10 @@ describe("createAnthropicContextWindowLimitRecoveryHook", () => {
parseAnthropicTokenLimitErrorMock.mockClear()
})
afterEach(() => {
mock.restore()
})
test("cancels pending timer when session.idle handles compaction first", async () => {
//#given
const { restore, getClearTimeoutCalls } = setupDelayedTimeoutMocks()