From bc7f84571481d60149d73b53ea05bc1ee20dd810 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 5 Apr 2026 12:51:51 +0100 Subject: [PATCH] test: speed up focused pi-tools tool tests --- ...aliases-schemas-without-dropping-b.test.ts | 1 + ...i-tools.deferred-followup-guidance.test.ts | 1 + .../pi-tools.whatsapp-login-gating.test.ts | 1 + .../test-helpers/fast-openclaw-tools.ts | 46 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 src/agents/test-helpers/fast-openclaw-tools.ts diff --git a/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-b.test.ts b/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-b.test.ts index a9e96caca26..02985f66218 100644 --- a/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-b.test.ts +++ b/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-b.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import "./test-helpers/fast-coding-tools.js"; +import "./test-helpers/fast-openclaw-tools.js"; import { createOpenClawCodingTools } from "./pi-tools.js"; const defaultTools = createOpenClawCodingTools({ senderIsOwner: true }); diff --git a/src/agents/pi-tools.deferred-followup-guidance.test.ts b/src/agents/pi-tools.deferred-followup-guidance.test.ts index bfbfdde31d2..3d7d4174293 100644 --- a/src/agents/pi-tools.deferred-followup-guidance.test.ts +++ b/src/agents/pi-tools.deferred-followup-guidance.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import "./test-helpers/fast-openclaw-tools.js"; import { createOpenClawCodingTools } from "./pi-tools.js"; function findToolDescription(toolName: string, senderIsOwner: boolean) { diff --git a/src/agents/pi-tools.whatsapp-login-gating.test.ts b/src/agents/pi-tools.whatsapp-login-gating.test.ts index e394487e993..214aa2c1197 100644 --- a/src/agents/pi-tools.whatsapp-login-gating.test.ts +++ b/src/agents/pi-tools.whatsapp-login-gating.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi } from "vitest"; import "./test-helpers/fast-coding-tools.js"; +import "./test-helpers/fast-openclaw-tools.js"; import { createOpenClawCodingTools } from "./pi-tools.js"; vi.mock("./channel-tools.js", () => { diff --git a/src/agents/test-helpers/fast-openclaw-tools.ts b/src/agents/test-helpers/fast-openclaw-tools.ts new file mode 100644 index 00000000000..ffbcc8a33f9 --- /dev/null +++ b/src/agents/test-helpers/fast-openclaw-tools.ts @@ -0,0 +1,46 @@ +import { vi } from "vitest"; +import { stubTool } from "./fast-tool-stubs.js"; + +function stubActionTool(name: string, actions: string[]) { + return { + ...stubTool(name), + parameters: { + type: "object" as const, + properties: { + action: { + type: "string" as const, + enum: actions, + }, + }, + required: ["action"], + }, + }; +} + +const coreTools = [ + stubActionTool("canvas", ["create", "read"]), + stubActionTool("nodes", ["list", "invoke"]), + stubActionTool("cron", ["schedule", "cancel"]), + stubActionTool("message", ["send", "reply"]), + stubActionTool("gateway", ["status"]), + stubActionTool("agents_list", ["list", "show"]), + stubActionTool("sessions_list", ["list", "show"]), + stubActionTool("sessions_history", ["read", "tail"]), + stubActionTool("sessions_send", ["send", "reply"]), + stubActionTool("sessions_spawn", ["spawn", "handoff"]), + stubActionTool("subagents", ["list", "show"]), + stubActionTool("session_status", ["get", "show"]), + stubTool("tts"), + stubTool("image_generate"), + stubTool("web_search"), + stubTool("web_fetch"), + stubTool("image"), + stubTool("pdf"), +]; + +vi.mock("../openclaw-tools.js", () => ({ + createOpenClawTools: () => coreTools.map((tool) => ({ ...tool })), + __testing: { + setDepsForTest: () => {}, + }, +}));