From 0c317c4c5c9614568c597430a097fa50bdcd45b4 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 3 Oct 2026 23:21:10 +0800 Subject: [PATCH] test: fix 7 typecheck errors in ws-lane and preflight-400 test files tests/ entered the root tsconfig typecheck scope in 2e6e508a (which also cleared the pre-existing backlog), but the WS-lane merges (#1968) and #1994 shipped test files that never passed that gate. Fix is entirely test-side: explicit Item[] casts where JSON.parse results were consumed as unknown (codex-responses-ws x3), import ProxyOptions from its canonical home src/config.ts instead of the local alias in server.ts (issue1993), and Promise-typed fakes in ws-bridge (dispatch callback + close promise). Closes #2003 --- tests/codex-responses-ws.test.ts | 6 +++--- tests/issue1993-preflight-400.test.ts | 3 ++- tests/ws-bridge.test.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/codex-responses-ws.test.ts b/tests/codex-responses-ws.test.ts index adebd3b3e5..ae5892c997 100644 --- a/tests/codex-responses-ws.test.ts +++ b/tests/codex-responses-ws.test.ts @@ -141,7 +141,7 @@ test("codex WS: prewarm probe plus full-replay turns ride the prefix lane throug assert.match(String(f.rows[0].headers["user-agent"]), /^codex_exec\//); // The real turn is a full replay the pipeline processed: bili's ACP // tools ride alongside codex's own (empty) tool list. - assert.ok(Array.isArray(f.rows[1].request.tools) && (f.rows[1].request.tools as Item[]).some(t => t.name === "acp_status" || t.name === "compress"), JSON.stringify(f.rows[1].request.tools?.map?.((t: Item) => t.name))); + assert.ok(Array.isArray(f.rows[1].request.tools) && (f.rows[1].request.tools as Item[]).some(t => t.name === "acp_status" || t.name === "compress"), JSON.stringify((f.rows[1].request.tools as Item[] | undefined)?.map(t => t.name))); assert.ok(JSON.stringify(f.rows[1].request.input).includes("codex-first-turn")); const session = peekSession(f.sid); assert.ok(session); @@ -189,7 +189,7 @@ test("codex WS: folding covered history shrinks the replayed turn", { timeout: 3 }; await play("session purpose: codex prefix-lane ACP integration"); await play("OLD-BULKY-SENTINEL " + "unique filler content ".repeat(1200)); - const firstText = JSON.stringify(f.rows.at(-1)!.request.input.find(item => JSON.stringify(item).includes("OLD-BULKY-SENTINEL"))); + const firstText = JSON.stringify((f.rows.at(-1)!.request.input as Item[]).find(item => JSON.stringify(item).includes("OLD-BULKY-SENTINEL"))); const ref = firstText.match(/\x3cacp[^\x3e]*\x3e(m\d+)\x3c\/acp\x3e/)?.[1]; assert.ok(ref, firstText.slice(-300)); for (let i = 0; i < 4; i++) await play(`push ${i}`); @@ -239,6 +239,6 @@ test("codex WS: non-streaming transport options are refused with a protocol erro f.peer.send(f.frame([user("nope")], { stream: false })); const error = await done; assert.equal(error.type, "error"); - assert.equal(error.error.code, "invalid_request"); + assert.equal((error.error as Item).code, "invalid_request"); } finally { await f.close(); } }); diff --git a/tests/issue1993-preflight-400.test.ts b/tests/issue1993-preflight-400.test.ts index c4d5398b24..fbe4edb4ef 100644 --- a/tests/issue1993-preflight-400.test.ts +++ b/tests/issue1993-preflight-400.test.ts @@ -14,7 +14,8 @@ process.env.BILI_REPLAY_RETRY_BASE_MS = "0"; process.env.BILI_PREFLIGHT_DEAD_END_COOLDOWN_MS = "400"; import { defaultConfig } from "acp-kernel"; -import { startServer, type ProxyOptions } from "../src/server.ts"; +import { startServer } from "../src/server.ts"; +import type { ProxyOptions } from "../src/config.ts"; import { SessionStore, _setStoreForTest } from "../src/persist.ts"; import { _setForTest as setRegistryForTest } from "../src/registry.ts"; import { listSessions } from "../src/session.ts"; diff --git a/tests/ws-bridge.test.ts b/tests/ws-bridge.test.ts index 002336faad..6d2a20fa7e 100644 --- a/tests/ws-bridge.test.ts +++ b/tests/ws-bridge.test.ts @@ -42,7 +42,7 @@ const fakeCodec: WsBridgeCodec = { async function harness(codecs: readonly WsBridgeCodec[]) { const server = http.createServer((_req, res) => res.writeHead(404).end()); const logs: string[] = []; - const handler = installWebSocketBridge(server, (_req, res) => Promise.resolve(res.writeHead(200).end()), (level, message) => logs.push(`${level} ${message}`), codecs); + const handler = installWebSocketBridge(server, async (_req, res) => { res.writeHead(200).end(); }, (level, message) => logs.push(`${level} ${message}`), codecs); server.on("upgrade", (req, socket, head) => { if (!handler(req, socket, head)) socket.destroy(); }); await new Promise(resolve => server.listen(0, "127.0.0.1", resolve)); return { server, handler, logs, port: (server.address() as AddressInfo).port }; @@ -108,6 +108,6 @@ test("ws bridge: server close shuts every session down and terminates peers", as assert.deepEqual(session.shutdowns, ["server-close"]); assert.equal(socket.readyState, WebSocket.CLOSED); } finally { - await new Promise(resolve => upstream.close(() => resolve())); + await new Promise(resolve => upstream.close(() => resolve())); } });