diff --git a/packages/coding-agent/test/agent-session-python-cleanup.test.ts b/packages/coding-agent/test/agent-session-python-cleanup.test.ts index d47e2382d..478fc5fb7 100644 --- a/packages/coding-agent/test/agent-session-python-cleanup.test.ts +++ b/packages/coding-agent/test/agent-session-python-cleanup.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test"; +import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from "bun:test"; import * as fs from "node:fs"; import * as os from "node:os"; import * as path from "node:path"; @@ -92,6 +92,15 @@ const mockPositiveSleepsImmediate = () => { return realSleep(duration ?? 0); }); }; + +const expectSleepNear = (sleepSpy: Mock, targetMs: number) => { + const minMs = targetMs - 100; + expect( + sleepSpy.mock.calls.some( + ([duration]) => typeof duration === "number" && duration >= minMs && duration <= targetMs, + ), + ).toBe(true); +}; const createSession = async ( tempDir: string, cwd: string, @@ -415,7 +424,7 @@ describe("AgentSession python cleanup", () => { const [toolResult] = await Promise.all([toolExecution, disposeSession]); - expect(sleepSpy).toHaveBeenCalledWith(3000); + expectSleepNear(sleepSpy, 3000); expect(disposed).toBe(true); expect(toolExecutionSettled).toBe(true); @@ -460,7 +469,7 @@ describe("AgentSession python cleanup", () => { firstDisposed = true; }); await disposeFirst; - expect(sleepSpy).toHaveBeenCalledWith(3000); + expectSleepNear(sleepSpy, 3000); expect(firstDisposed).toBe(true); expect(firstExecutionSettled).toBe(false); @@ -708,7 +717,7 @@ describe("AgentSession python cleanup", () => { const sleepSpy = mockPositiveSleepsImmediate(); await session.dispose(); - expect(sleepSpy).toHaveBeenCalledWith(3000); + expectSleepNear(sleepSpy, 3000); const [firstResult, secondResult] = await Promise.all([firstExecution, secondExecution]); expect(firstResult.cancelled).toBe(true); diff --git a/packages/coding-agent/test/cli-hide-thinking-flag.test.ts b/packages/coding-agent/test/cli-hide-thinking-flag.test.ts index a801ae446..4b4dcf949 100644 --- a/packages/coding-agent/test/cli-hide-thinking-flag.test.ts +++ b/packages/coding-agent/test/cli-hide-thinking-flag.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "bun:test"; +import { Effort } from "@oh-my-pi/pi-ai"; import { parseArgs } from "../src/cli/args"; describe("parseArgs — --hide-thinking flag", () => { @@ -20,9 +21,9 @@ describe("parseArgs — --hide-thinking flag", () => { }); it("parses --hide-thinking with --thinking flag (both can coexist)", () => { - const result = parseArgs(["--hide-thinking", "--thinking", "extended"]); + const result = parseArgs(["--hide-thinking", "--thinking", "xhigh"]); expect(result.hideThinking).toBe(true); - expect(result.thinking).toBe("extended"); + expect(result.thinking).toBe(Effort.XHigh); }); it("parses --hide-thinking in any position", () => {