From ca7204537c7da37ada5899a5efaf12661ba9dca8 Mon Sep 17 00:00:00 2001 From: Kevin Alwell Date: Tue, 29 Apr 2025 12:14:46 -0400 Subject: [PATCH] TypeScript bug bashing --- .../disableResponseStorage.agentLoop.test.ts | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/codex-cli/tests/disableResponseStorage.agentLoop.test.ts b/codex-cli/tests/disableResponseStorage.agentLoop.test.ts index 8b3bbd70a1..25572db389 100644 --- a/codex-cli/tests/disableResponseStorage.agentLoop.test.ts +++ b/codex-cli/tests/disableResponseStorage.agentLoop.test.ts @@ -8,11 +8,9 @@ import { describe, it, expect, vi } from "vitest"; import { AgentLoop } from "../src/utils/agent/agent-loop"; import type { AppConfig } from "../src/utils/config"; -import type { ReviewDecision } from "../src/utils/agent/types"; -// If you have a ReviewDecision type or enum, import it here: -// import type { ReviewDecision } from "../src/utils/agent/types"; +import { ReviewDecision } from "../src/utils/agent/review"; -/* ─────────── 1. Spy + module mock ──────────────────────────────── */ +/* ─────────── 1. Spy + module mock ─────────────────────────────── */ const createSpy = vi.fn().mockResolvedValue({ data: { id: "resp_123", status: "completed", output: [] }, }); @@ -52,9 +50,7 @@ describe.each([ additionalWritableRoots: [], onItem() {}, onLoading() {}, - getCommandConfirmation: async () => ({ - review: "approved" as ReviewDecision, - }), + getCommandConfirmation: async () => ({ review: ReviewDecision.YES }), onLastResponseId() {}, }); @@ -68,26 +64,22 @@ describe.each([ expect(createSpy).toHaveBeenCalledTimes(1); - const payload = createSpy.mock.calls[0][0]; + const payload: any = createSpy.mock.calls[0][0]; if (flag) { /* behaviour when ZDR is *on* */ expect(payload).not.toHaveProperty("previous_response_id"); - if (payload.input) { - payload.input.forEach((m: any) => - expect(m.store === undefined ? false : m.store).toBe(false), - ); - } + payload.input?.forEach((m: any) => + expect(m.store === undefined ? false : m.store).toBe(false), + ); } else { /* behaviour when ZDR is *off* */ expect(payload).toHaveProperty("previous_response_id"); - if (payload.input) { - payload.input.forEach((m: any) => { - if ("store" in m) { - expect(m.store).not.toBe(false); - } - }); - } + payload.input?.forEach((m: any) => { + if ("store" in m) { + expect(m.store).not.toBe(false); + } + }); } }); });