From fe62711342cfa2781b8f7e2f39fb8c00ee03e248 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 23 Feb 2026 19:19:39 +0000 Subject: [PATCH] test(gate): stabilize env- and timing-sensitive process/web-search checks --- .../bash-tools.process.send-keys.test.ts | 2 +- src/config/config.web-search-provider.test.ts | 12 ++++++++++++ src/process/exec.test.ts | 2 +- src/process/supervisor/supervisor.test.ts | 19 +++++++++++-------- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/agents/bash-tools.process.send-keys.test.ts b/src/agents/bash-tools.process.send-keys.test.ts index 96fb6bdc8b7..e077688093e 100644 --- a/src/agents/bash-tools.process.send-keys.test.ts +++ b/src/agents/bash-tools.process.send-keys.test.ts @@ -43,7 +43,7 @@ async function waitForSessionCompletion(params: { return true; }, { - timeout: process.platform === "win32" ? 4000 : 2000, + timeout: process.platform === "win32" ? 12_000 : 8_000, interval: 30, }, ) diff --git a/src/config/config.web-search-provider.test.ts b/src/config/config.web-search-provider.test.ts index bc366ac8b48..ca3774e4ea1 100644 --- a/src/config/config.web-search-provider.test.ts +++ b/src/config/config.web-search-provider.test.ts @@ -72,6 +72,8 @@ describe("web search provider auto-detection", () => { delete process.env.PERPLEXITY_API_KEY; delete process.env.OPENROUTER_API_KEY; delete process.env.XAI_API_KEY; + delete process.env.KIMI_API_KEY; + delete process.env.MOONSHOT_API_KEY; }); afterEach(() => { @@ -103,6 +105,16 @@ describe("web search provider auto-detection", () => { expect(resolveSearchProvider({})).toBe("grok"); }); + it("auto-detects kimi when only KIMI_API_KEY is set", () => { + process.env.KIMI_API_KEY = "test-kimi-key"; + expect(resolveSearchProvider({})).toBe("kimi"); + }); + + it("auto-detects kimi when only MOONSHOT_API_KEY is set", () => { + process.env.MOONSHOT_API_KEY = "test-moonshot-key"; + expect(resolveSearchProvider({})).toBe("kimi"); + }); + it("follows priority order — brave wins when multiple keys available", () => { process.env.BRAVE_API_KEY = "test-brave-key"; process.env.GEMINI_API_KEY = "test-gemini-key"; diff --git a/src/process/exec.test.ts b/src/process/exec.test.ts index a3bfef87cb0..1f41edaa040 100644 --- a/src/process/exec.test.ts +++ b/src/process/exec.test.ts @@ -110,7 +110,7 @@ describe("runCommandWithTimeout", () => { ], { timeoutMs: 5_000, - noOutputTimeoutMs: 500, + noOutputTimeoutMs: 1_500, }, ); diff --git a/src/process/supervisor/supervisor.test.ts b/src/process/supervisor/supervisor.test.ts index 02f318ee3c4..2a43d19e8d7 100644 --- a/src/process/supervisor/supervisor.test.ts +++ b/src/process/supervisor/supervisor.test.ts @@ -18,8 +18,9 @@ describe("process supervisor", () => { const supervisor = createProcessSupervisor(); const run = await spawnChild(supervisor, { sessionId: "s1", - argv: [process.execPath, "-e", 'process.stdout.write("ok")'], - timeoutMs: 1_000, + // Delay stdout slightly so listeners are attached even on heavily loaded runners. + argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("ok"), 200)'], + timeoutMs: 10_000, stdinMode: "pipe-closed", }); const exit = await run.wait(); @@ -48,8 +49,8 @@ describe("process supervisor", () => { const first = await spawnChild(supervisor, { sessionId: "s1", scopeKey: "scope:a", - argv: [process.execPath, "-e", "setTimeout(() => {}, 40)"], - timeoutMs: 500, + argv: [process.execPath, "-e", "setTimeout(() => {}, 2_000)"], + timeoutMs: 10_000, stdinMode: "pipe-open", }); @@ -57,8 +58,9 @@ describe("process supervisor", () => { sessionId: "s1", scopeKey: "scope:a", replaceExistingScope: true, - argv: [process.execPath, "-e", 'process.stdout.write("new")'], - timeoutMs: 1_000, + // Small delay makes stdout capture deterministic by giving listeners time to attach. + argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("new"), 200)'], + timeoutMs: 10_000, stdinMode: "pipe-closed", }); @@ -87,8 +89,9 @@ describe("process supervisor", () => { let streamed = ""; const run = await spawnChild(supervisor, { sessionId: "s-capture", - argv: [process.execPath, "-e", 'process.stdout.write("streamed")'], - timeoutMs: 1_000, + // Avoid race where child exits before stdout listeners are attached. + argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("streamed"), 200)'], + timeoutMs: 10_000, stdinMode: "pipe-closed", captureOutput: false, onStdout: (chunk) => {