test(feishu): slim tool runtime fixtures

This commit is contained in:
Vincent Koc 2026-04-03 21:16:58 +09:00
parent cd81e0a07b
commit 69da71c0ce
3 changed files with 22 additions and 13 deletions

View File

@ -23,6 +23,15 @@ type BindingReadiness = Awaited<
type ReplyDispatcher = Parameters<
PluginRuntime["channel"]["reply"]["withReplyDispatcher"]
>[0]["dispatcher"];
type DeepPartial<T> = {
[K in keyof T]?: T[K] extends (...args: never[]) => unknown
? T[K]
: T[K] extends ReadonlyArray<unknown>
? T[K]
: T[K] extends object
? DeepPartial<T[K]>
: T[K];
};
function createReplyDispatcher(): ReplyDispatcher {
return {
@ -163,13 +172,7 @@ function createUnboundConfiguredRoute(
return { bindingResolution: null, route };
}
function createFeishuBotRuntime(
overrides: Partial<PluginRuntime> & {
channel?: Partial<PluginRuntime["channel"]>;
system?: Partial<PluginRuntime["system"]>;
media?: Partial<PluginRuntime["media"]>;
} = {},
): PluginRuntime {
function createFeishuBotRuntime(overrides: DeepPartial<PluginRuntime> = {}): PluginRuntime {
return {
channel: {
routing: {

View File

@ -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,
});

View File

@ -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,
});