From 69da71c0ce35a0600ae4d8ac7ef200047ac5a273 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 3 Apr 2026 21:16:58 +0900 Subject: [PATCH] test(feishu): slim tool runtime fixtures --- extensions/feishu/src/bot.test.ts | 17 ++++++++++------- extensions/feishu/src/chat.test.ts | 9 ++++++--- extensions/feishu/src/drive.test.ts | 9 ++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/extensions/feishu/src/bot.test.ts b/extensions/feishu/src/bot.test.ts index cf39e03f4ce..738468bf301 100644 --- a/extensions/feishu/src/bot.test.ts +++ b/extensions/feishu/src/bot.test.ts @@ -23,6 +23,15 @@ type BindingReadiness = Awaited< type ReplyDispatcher = Parameters< PluginRuntime["channel"]["reply"]["withReplyDispatcher"] >[0]["dispatcher"]; +type DeepPartial = { + [K in keyof T]?: T[K] extends (...args: never[]) => unknown + ? T[K] + : T[K] extends ReadonlyArray + ? T[K] + : T[K] extends object + ? DeepPartial + : T[K]; +}; function createReplyDispatcher(): ReplyDispatcher { return { @@ -163,13 +172,7 @@ function createUnboundConfiguredRoute( return { bindingResolution: null, route }; } -function createFeishuBotRuntime( - overrides: Partial & { - channel?: Partial; - system?: Partial; - media?: Partial; - } = {}, -): PluginRuntime { +function createFeishuBotRuntime(overrides: DeepPartial = {}): PluginRuntime { return { channel: { routing: { diff --git a/extensions/feishu/src/chat.test.ts b/extensions/feishu/src/chat.test.ts index 6c80d826d48..f6b38de6250 100644 --- a/extensions/feishu/src/chat.test.ts +++ b/extensions/feishu/src/chat.test.ts @@ -1,7 +1,6 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { createTestPluginApi } from "../../../test/helpers/plugins/plugin-api.js"; -import { createPluginRuntimeMock } from "../../../test/helpers/plugins/plugin-runtime-mock.js"; -import type { OpenClawPluginApi } from "../runtime-api.js"; +import type { OpenClawPluginApi, PluginRuntime } from "../runtime-api.js"; const createFeishuClientMock = vi.hoisted(() => vi.fn()); const chatGetMock = vi.hoisted(() => vi.fn()); @@ -14,6 +13,10 @@ vi.mock("./client.js", () => ({ let registerFeishuChatTools: typeof import("./chat.js").registerFeishuChatTools; +function createFeishuToolRuntime(): PluginRuntime { + return {} as PluginRuntime; +} + describe("registerFeishuChatTools", () => { function createChatToolApi(params: { config: OpenClawPluginApi["config"]; @@ -24,7 +27,7 @@ describe("registerFeishuChatTools", () => { name: "Feishu Test", source: "local", config: params.config, - runtime: createPluginRuntimeMock(), + runtime: createFeishuToolRuntime(), logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }, registerTool: params.registerTool, }); diff --git a/extensions/feishu/src/drive.test.ts b/extensions/feishu/src/drive.test.ts index aee7a4c699c..56415f48a47 100644 --- a/extensions/feishu/src/drive.test.ts +++ b/extensions/feishu/src/drive.test.ts @@ -1,7 +1,6 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { createTestPluginApi } from "../../../test/helpers/plugins/plugin-api.js"; -import { createPluginRuntimeMock } from "../../../test/helpers/plugins/plugin-runtime-mock.js"; -import type { OpenClawPluginApi } from "../runtime-api.js"; +import type { OpenClawPluginApi, PluginRuntime } from "../runtime-api.js"; const createFeishuToolClientMock = vi.hoisted(() => vi.fn()); const resolveAnyEnabledFeishuToolsConfigMock = vi.hoisted(() => vi.fn()); @@ -13,6 +12,10 @@ vi.mock("./tool-account.js", () => ({ let registerFeishuDriveTools: typeof import("./drive.js").registerFeishuDriveTools; +function createFeishuToolRuntime(): PluginRuntime { + return {} as PluginRuntime; +} + function createDriveToolApi(params: { config: OpenClawPluginApi["config"]; registerTool: OpenClawPluginApi["registerTool"]; @@ -22,7 +25,7 @@ function createDriveToolApi(params: { name: "Feishu Test", source: "local", config: params.config, - runtime: createPluginRuntimeMock(), + runtime: createFeishuToolRuntime(), logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }, registerTool: params.registerTool, });