mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:18:37 +00:00
test(gate): stabilize env- and timing-sensitive process/web-search checks
This commit is contained in:
@@ -43,7 +43,7 @@ async function waitForSessionCompletion(params: {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: process.platform === "win32" ? 4000 : 2000,
|
timeout: process.platform === "win32" ? 12_000 : 8_000,
|
||||||
interval: 30,
|
interval: 30,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ describe("web search provider auto-detection", () => {
|
|||||||
delete process.env.PERPLEXITY_API_KEY;
|
delete process.env.PERPLEXITY_API_KEY;
|
||||||
delete process.env.OPENROUTER_API_KEY;
|
delete process.env.OPENROUTER_API_KEY;
|
||||||
delete process.env.XAI_API_KEY;
|
delete process.env.XAI_API_KEY;
|
||||||
|
delete process.env.KIMI_API_KEY;
|
||||||
|
delete process.env.MOONSHOT_API_KEY;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -103,6 +105,16 @@ describe("web search provider auto-detection", () => {
|
|||||||
expect(resolveSearchProvider({})).toBe("grok");
|
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", () => {
|
it("follows priority order — brave wins when multiple keys available", () => {
|
||||||
process.env.BRAVE_API_KEY = "test-brave-key";
|
process.env.BRAVE_API_KEY = "test-brave-key";
|
||||||
process.env.GEMINI_API_KEY = "test-gemini-key";
|
process.env.GEMINI_API_KEY = "test-gemini-key";
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ describe("runCommandWithTimeout", () => {
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
timeoutMs: 5_000,
|
timeoutMs: 5_000,
|
||||||
noOutputTimeoutMs: 500,
|
noOutputTimeoutMs: 1_500,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ describe("process supervisor", () => {
|
|||||||
const supervisor = createProcessSupervisor();
|
const supervisor = createProcessSupervisor();
|
||||||
const run = await spawnChild(supervisor, {
|
const run = await spawnChild(supervisor, {
|
||||||
sessionId: "s1",
|
sessionId: "s1",
|
||||||
argv: [process.execPath, "-e", 'process.stdout.write("ok")'],
|
// Delay stdout slightly so listeners are attached even on heavily loaded runners.
|
||||||
timeoutMs: 1_000,
|
argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("ok"), 200)'],
|
||||||
|
timeoutMs: 10_000,
|
||||||
stdinMode: "pipe-closed",
|
stdinMode: "pipe-closed",
|
||||||
});
|
});
|
||||||
const exit = await run.wait();
|
const exit = await run.wait();
|
||||||
@@ -48,8 +49,8 @@ describe("process supervisor", () => {
|
|||||||
const first = await spawnChild(supervisor, {
|
const first = await spawnChild(supervisor, {
|
||||||
sessionId: "s1",
|
sessionId: "s1",
|
||||||
scopeKey: "scope:a",
|
scopeKey: "scope:a",
|
||||||
argv: [process.execPath, "-e", "setTimeout(() => {}, 40)"],
|
argv: [process.execPath, "-e", "setTimeout(() => {}, 2_000)"],
|
||||||
timeoutMs: 500,
|
timeoutMs: 10_000,
|
||||||
stdinMode: "pipe-open",
|
stdinMode: "pipe-open",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,8 +58,9 @@ describe("process supervisor", () => {
|
|||||||
sessionId: "s1",
|
sessionId: "s1",
|
||||||
scopeKey: "scope:a",
|
scopeKey: "scope:a",
|
||||||
replaceExistingScope: true,
|
replaceExistingScope: true,
|
||||||
argv: [process.execPath, "-e", 'process.stdout.write("new")'],
|
// Small delay makes stdout capture deterministic by giving listeners time to attach.
|
||||||
timeoutMs: 1_000,
|
argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("new"), 200)'],
|
||||||
|
timeoutMs: 10_000,
|
||||||
stdinMode: "pipe-closed",
|
stdinMode: "pipe-closed",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,8 +89,9 @@ describe("process supervisor", () => {
|
|||||||
let streamed = "";
|
let streamed = "";
|
||||||
const run = await spawnChild(supervisor, {
|
const run = await spawnChild(supervisor, {
|
||||||
sessionId: "s-capture",
|
sessionId: "s-capture",
|
||||||
argv: [process.execPath, "-e", 'process.stdout.write("streamed")'],
|
// Avoid race where child exits before stdout listeners are attached.
|
||||||
timeoutMs: 1_000,
|
argv: [process.execPath, "-e", 'setTimeout(() => process.stdout.write("streamed"), 200)'],
|
||||||
|
timeoutMs: 10_000,
|
||||||
stdinMode: "pipe-closed",
|
stdinMode: "pipe-closed",
|
||||||
captureOutput: false,
|
captureOutput: false,
|
||||||
onStdout: (chunk) => {
|
onStdout: (chunk) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user