test(anthropic-recovery): isolate summarize retry timer assertion

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 15:39:44 +09:00
parent 5e8a0ccf84
commit 42ac82a94a
@@ -4,6 +4,7 @@ import type { AutoCompactState, ParsedTokenLimitError, RetryState } from "./type
import type { OhMyOpenCodeConfig } from "../../config" import type { OhMyOpenCodeConfig } from "../../config"
type TimeoutCall = { type TimeoutCall = {
handle: ReturnType<typeof setTimeout>
delay: number delay: number
} }
@@ -94,8 +95,9 @@ describe("runSummarizeRetryStrategy", () => {
//#given //#given
const timeoutCalls: TimeoutCall[] = [] const timeoutCalls: TimeoutCall[] = []
globalThis.setTimeout = ((_: (...args: unknown[]) => void, delay?: number) => { globalThis.setTimeout = ((_: (...args: unknown[]) => void, delay?: number) => {
timeoutCalls.push({ delay: delay ?? 0 }) const handle = timeoutCalls.length + 1 as unknown as ReturnType<typeof setTimeout>
return 1 as unknown as ReturnType<typeof setTimeout> timeoutCalls.push({ handle, delay: delay ?? 0 })
return handle
}) as typeof setTimeout }) as typeof setTimeout
autoCompactState.pendingCompact.add(sessionID) autoCompactState.pendingCompact.add(sessionID)
@@ -117,9 +119,12 @@ describe("runSummarizeRetryStrategy", () => {
}) })
//#then //#then
expect(timeoutCalls.length).toBe(1) const retryTimer = autoCompactState.retryTimerBySession.get(sessionID)
expect(timeoutCalls[0]!.delay).toBeGreaterThan(0) const retryTimeoutCall = timeoutCalls.find(({ handle }) => handle === retryTimer)
expect(timeoutCalls[0]!.delay).toBeLessThanOrEqual(2000)
expect(retryTimeoutCall).toBeDefined()
expect(retryTimeoutCall?.delay).toBeGreaterThan(0)
expect(retryTimeoutCall?.delay).toBeLessThanOrEqual(2000)
}) })
test("#given pending retry timer after session cleanup #when scheduled callback fires #then it does not recreate retry state", async () => { test("#given pending retry timer after session cleanup #when scheduled callback fires #then it does not recreate retry state", async () => {