Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test: stabilize progress polling and cover literal Windows paths (#2179)

Dipesh Babue50da33612ec
diff --git a/sdk/typescript/tests-ts/cost.test.ts b/sdk/typescript/tests-ts/cost.test.ts
index 4396a27f2..8470317f5 100644
--- a/sdk/typescript/tests-ts/cost.test.ts
+++ b/sdk/typescript/tests-ts/cost.test.ts
@@ -1029,7 +1029,18 @@ describe("inventory source ordering", () => {
return handle;
},
);
- tracker.start("scan-thread");
+ // These cases stage writes and close hooks around explicit refreshes.
+ // A periodic poll must not consume the rows before those hooks are ready.
+ const originalSetInterval = globalThis.setInterval;
+ const polling = spyOn(globalThis, "setInterval").mockImplementationOnce(((
+ _: unknown,
+ delay?: number,
+ ) => originalSetInterval(() => {}, delay)) as typeof originalSetInterval);
+ try {
+ tracker.start("scan-thread");
+ } finally {
+ polling.mockRestore();
+ }
await tracker.refresh();
tracker.beginParentTurn();
return {
diff --git a/sdk/typescript/tests-ts/scan-activity.test.ts b/sdk/typescript/tests-ts/scan-activity.test.ts
index 4c07f371c..ec6bc489d 100644
--- a/sdk/typescript/tests-ts/scan-activity.test.ts
+++ b/sdk/typescript/tests-ts/scan-activity.test.ts
@@ -576,6 +576,16 @@ describe("scan activity", () => {
(repository, path, inside) => {
const paths = inside ? ["Src/A.ts"] : [];
const cmd = `type "${path}"`;
+ expect(
+ scanActivityFromSessionEvent(
+ sessionEvent({
+ type: "local_shell_call",
+ call_id: "worker-argv",
+ action: { type: "exec", command: ["cat", path] },
+ }),
+ repository,
+ ),
+ ).toMatchObject({ paths });
expect(
scanActivityFromEvent(toolEvent("read_file", { path }), repository),
).toMatchObject({ paths });