From 89d2b5ead3d588f0eb1c626d3c1a0de92eadeddf Mon Sep 17 00:00:00 2001 From: suraj-markup Date: Wed, 25 Feb 2026 11:51:09 +0530 Subject: [PATCH] test(agent-codex): add missing setupMockStream calls to edge-case tests Three tests relied on the empty default stream coincidentally matching expected values instead of actually exercising the streaming parser. Added setupMockStream(content) and stronger assertions to verify the parser correctly handles missing model, missing token events, and missing threadId. Co-Authored-By: Claude Opus 4.6 --- packages/plugins/agent-codex/src/index.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/plugins/agent-codex/src/index.test.ts b/packages/plugins/agent-codex/src/index.test.ts index 1cee65eb3..f272775bd 100644 --- a/packages/plugins/agent-codex/src/index.test.ts +++ b/packages/plugins/agent-codex/src/index.test.ts @@ -738,13 +738,17 @@ describe("getSessionInfo", () => { mockReaddir.mockResolvedValue(["sess.jsonl"]); setupMockOpen(content); - mockReadFile.mockResolvedValue(content); + setupMockStream(content); mockStat.mockResolvedValue({ mtimeMs: 1000 }); const result = await agent.getSessionInfo(makeSession({ workspacePath: "/workspace/test" })); expect(result).not.toBeNull(); expect(result!.summary).toBeNull(); + // Verify cost was actually parsed from the stream (not just defaulting to undefined) + expect(result!.cost).toBeDefined(); + expect(result!.cost!.inputTokens).toBe(100); + expect(result!.cost!.outputTokens).toBe(50); }); it("returns undefined cost when no token_count events", async () => { @@ -755,13 +759,15 @@ describe("getSessionInfo", () => { mockReaddir.mockResolvedValue(["sess.jsonl"]); setupMockOpen(content); - mockReadFile.mockResolvedValue(content); + setupMockStream(content); mockStat.mockResolvedValue({ mtimeMs: 1000 }); const result = await agent.getSessionInfo(makeSession({ workspacePath: "/workspace/test" })); expect(result).not.toBeNull(); expect(result!.cost).toBeUndefined(); + // Verify model was actually parsed from the stream (not just defaulting to null) + expect(result!.summary).toContain("gpt-4o"); }); it("handles unreadable session files gracefully", async () => { @@ -900,7 +906,7 @@ describe("getRestoreCommand", () => { ); mockReaddir.mockResolvedValue(["sess.jsonl"]); setupMockOpen(content); - mockReadFile.mockResolvedValue(content); + setupMockStream(content); mockStat.mockResolvedValue({ mtimeMs: 1000 }); const session = makeSession({ workspacePath: "/workspace/test" });