test: tighten extension test call typing

This commit is contained in:
Peter Steinberger
2026-05-11 11:14:12 +01:00
parent 3e31b0946f
commit 36e457aa72
2 changed files with 38 additions and 30 deletions

View File

@@ -261,7 +261,7 @@ describe("CONSENT_UPLOAD_HOST_ALLOWLIST", () => {
describe("uploadToConsentUrl", () => {
it("sends the OpenClaw User-Agent header with consent uploads", async () => {
const fetchFn = vi.fn(async () => new Response(null, { status: 200 }));
const fetchFn = vi.fn<typeof fetch>(async () => new Response(null, { status: 200 }));
await uploadToConsentUrl({
url: "https://contoso.sharepoint.com/upload",

View File

@@ -94,14 +94,13 @@ describe("qa suite runtime agent process helpers", () => {
child.emit("exit", 0);
await expect(pending).resolves.toBe("ok");
expect(spawnMock).toHaveBeenCalledWith(
"/usr/bin/node",
[path.join("/repo", "dist", "index.js"), "qa", "suite"],
expect.objectContaining({
cwd: "/tmp/runtime",
env: { PATH: "/usr/bin" },
}),
const spawnCall = spawnMock.mock.calls[0];
expect(spawnCall?.[0]).toBe("/usr/bin/node");
expect(spawnCall?.[1]).toEqual([path.join("/repo", "dist", "index.js"), "qa", "suite"]);
expect((spawnCall?.[2] as { cwd?: string; env?: unknown } | undefined)?.cwd).toBe(
"/tmp/runtime",
);
expect((spawnCall?.[2] as { env?: unknown } | undefined)?.env).toEqual({ PATH: "/usr/bin" });
});
it("merges isolated env overrides into qa cli runs", async () => {
@@ -133,17 +132,18 @@ describe("qa suite runtime agent process helpers", () => {
child.emit("exit", 0);
await expect(pending).resolves.toBe("ok");
expect(spawnMock).toHaveBeenCalledWith(
"/usr/bin/node",
[path.join("/repo", "dist", "index.js"), "crestodian", "-m", "overview"],
expect.objectContaining({
env: expect.objectContaining({
PATH: "/usr/bin",
OPENCLAW_STATE_DIR: "/tmp/isolated-state",
OPENCLAW_CONFIG_PATH: "/tmp/isolated-state/openclaw.json",
}),
}),
);
const spawnCall = spawnMock.mock.calls[0];
expect(spawnCall?.[0]).toBe("/usr/bin/node");
expect(spawnCall?.[1]).toEqual([
path.join("/repo", "dist", "index.js"),
"crestodian",
"-m",
"overview",
]);
const spawnEnv = (spawnCall?.[2] as { env?: Record<string, string> } | undefined)?.env;
expect(spawnEnv?.PATH).toBe("/usr/bin");
expect(spawnEnv?.OPENCLAW_STATE_DIR).toBe("/tmp/isolated-state");
expect(spawnEnv?.OPENCLAW_CONFIG_PATH).toBe("/tmp/isolated-state/openclaw.json");
});
it("parses json qa cli output when requested", async () => {
@@ -253,17 +253,25 @@ describe("qa suite runtime agent process helpers", () => {
message: "hello",
}),
).resolves.toEqual({ runId: "run-1" });
expect(gatewayCall).toHaveBeenCalledWith(
"agent",
expect.objectContaining({
sessionKey: "session-1",
message: "hello",
channel: "qa-channel",
replyChannel: "reply-channel",
replyTo: "reply-target",
}),
expect.any(Object),
);
const gatewayArgs = gatewayCall.mock.calls[0] as unknown as
| [string, unknown, unknown]
| undefined;
expect(gatewayArgs?.[0]).toBe("agent");
const agentPayload = gatewayArgs?.[1] as
| {
channel?: string;
message?: string;
replyChannel?: string;
replyTo?: string;
sessionKey?: string;
}
| undefined;
expect(agentPayload?.sessionKey).toBe("session-1");
expect(agentPayload?.message).toBe("hello");
expect(agentPayload?.channel).toBe("qa-channel");
expect(agentPayload?.replyChannel).toBe("reply-channel");
expect(agentPayload?.replyTo).toBe("reply-target");
expect(gatewayArgs?.[2]).toEqual(expect.any(Object));
});
it("finds managed dreaming cron jobs across legacy and current payload contracts", () => {