From 8e80716169e22f2d9a0a621a466d7df3a712310c Mon Sep 17 00:00:00 2001 From: Kevin Alwell Date: Tue, 29 Apr 2025 12:10:54 -0400 Subject: [PATCH] fix tests --- .../disableResponseStorage.agentLoop.test.ts | 25 ++++++++----------- .../tests/disableResponseStorage.test.ts | 4 +-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/codex-cli/tests/disableResponseStorage.agentLoop.test.ts b/codex-cli/tests/disableResponseStorage.agentLoop.test.ts index 71ad8605f9..15ffcfe2cd 100644 --- a/codex-cli/tests/disableResponseStorage.agentLoop.test.ts +++ b/codex-cli/tests/disableResponseStorage.agentLoop.test.ts @@ -58,7 +58,8 @@ describe.each([ await loop.run([ { type: "message", - content: [{ type: "text", text: "hello" }], + role: "user", + content: [{ type: "input_text", text: "hello" }], }, ]); @@ -69,23 +70,17 @@ describe.each([ 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) { - // first user message is usually non-stored; assistant messages will be stored - // so here we just assert the property is not forcibly set to false - 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); + } + }); } }); }); diff --git a/codex-cli/tests/disableResponseStorage.test.ts b/codex-cli/tests/disableResponseStorage.test.ts index d3f632fdde..a0118adfcb 100644 --- a/codex-cli/tests/disableResponseStorage.test.ts +++ b/codex-cli/tests/disableResponseStorage.test.ts @@ -3,7 +3,7 @@ */ import { describe, it, expect, beforeAll, afterAll } from "vitest"; -import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; @@ -17,7 +17,7 @@ describe("disableResponseStorage persistence", () => { beforeAll(() => { // mkdir -p ~/.codex inside the sandbox rmSync(codexDir, { recursive: true, force: true }); - require("fs").mkdirSync(codexDir, { recursive: true }); + mkdirSync(codexDir, { recursive: true }); // seed YAML with ZDR enabled writeFileSync(yamlPath, "model: o4-mini\ndisableResponseStorage: true\n");