From cd3074b2d1143083987c9907960cd36c6cf18cd5 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Tue, 28 Apr 2026 14:45:03 -0300 Subject: [PATCH] test: fix typescript compilation errors in unit tests --- tests/unit/executor-codex.test.ts | 4 ++-- tests/unit/responses-handler.test.ts | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/unit/executor-codex.test.ts b/tests/unit/executor-codex.test.ts index e27df7ba2f..77677224d3 100644 --- a/tests/unit/executor-codex.test.ts +++ b/tests/unit/executor-codex.test.ts @@ -24,7 +24,7 @@ test.afterEach(() => { __setCodexWebSocketTransportForTesting(undefined); }); -async function withEnv(entries, fn) { +async function withEnv(entries: Record, fn: () => any) { const previous = new Map(); for (const [key, value] of Object.entries(entries)) { @@ -379,7 +379,7 @@ test("CodexExecutor.execute falls back to HTTP when websocket transport is unava // When WS transport is unavailable, isCodexResponsesWebSocketRequired returns false // and the executor falls back to HTTP via super.execute() assert.equal(result.response.status, 200); - assert.equal(result.transformedBody.model, "gpt-5.5"); + assert.equal((result.transformedBody as any).model, "gpt-5.5"); } finally { globalThis.fetch = originalFetch; } diff --git a/tests/unit/responses-handler.test.ts b/tests/unit/responses-handler.test.ts index 60b0b07b77..af10c7f0d6 100644 --- a/tests/unit/responses-handler.test.ts +++ b/tests/unit/responses-handler.test.ts @@ -21,7 +21,7 @@ function noopLog() { }; } -function toPlainHeaders(headers) { +function toPlainHeaders(headers: any) { if (!headers) return {}; if (headers instanceof Headers) return Object.fromEntries(headers.entries()); return Object.fromEntries( @@ -55,7 +55,7 @@ function buildOpenAISseResponse(text = "hello") { ); } -function buildJsonResponse(status, payload) { +function buildJsonResponse(status: number, payload: any) { return new Response(JSON.stringify(payload), { status, headers: { "Content-Type": "application/json" }, @@ -75,8 +75,15 @@ async function invokeResponsesCore({ credentials, responseFactory, signal, +}: { + body?: any; + provider?: string; + model?: string; + credentials?: any; + responseFactory?: any; + signal?: AbortSignal; } = {}) { - const calls = []; + const calls: any[] = []; globalThis.fetch = async (url, init = {}) => { const call = { @@ -263,10 +270,10 @@ test("handleResponsesCore rejects invalid Responses API input that cannot be tra test("handleResponsesCore injects SSE keepalive comments for Responses streams", async () => { const originalSetInterval = globalThis.setInterval; const originalClearInterval = globalThis.clearInterval; - const intervals = []; + const intervals: any[] = []; let nextId = 0; - globalThis.setInterval = (callback, delay = 0, ...args) => { + (globalThis as any).setInterval = (callback: any, delay = 0, ...args: any[]) => { const interval = { id: ++nextId, callback, @@ -278,7 +285,7 @@ test("handleResponsesCore injects SSE keepalive comments for Responses streams", return interval; }; - globalThis.clearInterval = (interval) => { + (globalThis as any).clearInterval = (interval: any) => { if (interval && typeof interval === "object") { interval.cleared = true; } @@ -312,10 +319,10 @@ test("handleResponsesCore injects SSE keepalive comments for Responses streams", test("handleResponsesCore clears heartbeat timers immediately when the request signal aborts", async () => { const originalSetInterval = globalThis.setInterval; const originalClearInterval = globalThis.clearInterval; - const intervals = []; + const intervals: any[] = []; let nextId = 0; - globalThis.setInterval = (callback, delay = 0, ...args) => { + (globalThis as any).setInterval = (callback: any, delay = 0, ...args: any[]) => { const interval = { id: ++nextId, callback, @@ -327,7 +334,7 @@ test("handleResponsesCore clears heartbeat timers immediately when the request s return interval; }; - globalThis.clearInterval = (interval) => { + (globalThis as any).clearInterval = (interval: any) => { if (interval && typeof interval === "object") { interval.cleared = true; }