From fbe7e61ab41e727ffce6c723d1fa6f409f67458b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 21 Feb 2026 03:57:21 +0900 Subject: [PATCH] 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. --- .../recovery-hook.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts b/src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts index a0d799a2..72dd3746 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts @@ -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()