diff --git a/extensions/telegram/src/bot-native-commands.fixture-test-support.ts b/extensions/telegram/src/bot-native-commands.fixture-test-support.ts index f26ac028db3..99e8497ae7f 100644 --- a/extensions/telegram/src/bot-native-commands.fixture-test-support.ts +++ b/extensions/telegram/src/bot-native-commands.fixture-test-support.ts @@ -56,6 +56,7 @@ export function createNativeCommandTestParams( params.resolveTelegramGroupConfig ?? ((_chatId, _messageThreadId) => ({ groupConfig: undefined, topicConfig: undefined })), shouldSkipUpdate: params.shouldSkipUpdate ?? (() => false), + telegramDeps: params.telegramDeps, opts: params.opts ?? { token: "token" }, }; } diff --git a/extensions/telegram/src/bot-native-commands.menu-test-support.ts b/extensions/telegram/src/bot-native-commands.menu-test-support.ts index e37634e7d55..86eb7c4f65a 100644 --- a/extensions/telegram/src/bot-native-commands.menu-test-support.ts +++ b/extensions/telegram/src/bot-native-commands.menu-test-support.ts @@ -1,6 +1,7 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env"; import type { OpenClawConfig } from "openclaw/plugin-sdk/telegram"; import { expect, vi } from "vitest"; +import type { TelegramBotDeps } from "./bot-deps.js"; import { createNativeCommandTestParams as createBaseNativeCommandTestParams, createTelegramPrivateCommandContext, @@ -78,10 +79,23 @@ export function createNativeCommandTestParams( cfg: OpenClawConfig, params: Partial = {}, ): RegisterTelegramNativeCommandsParams { + const telegramDeps: TelegramBotDeps = { + loadConfig: vi.fn(() => ({})), + resolveStorePath: vi.fn((storePath?: string) => storePath ?? "/tmp/sessions.json"), + readChannelAllowFromStore: vi.fn(async () => []), + enqueueSystemEvent: vi.fn(), + dispatchReplyWithBufferedBlockDispatcher: vi.fn(async () => ({ + queuedFinal: false, + counts: {}, + })), + listSkillCommandsForAgents, + wasSentByBot: vi.fn(() => false), + }; return createBaseNativeCommandTestParams({ cfg, runtime: params.runtime ?? ({} as RuntimeEnv), nativeSkillsEnabled: true, + telegramDeps, ...params, }); } diff --git a/extensions/telegram/src/bot-native-commands.test.ts b/extensions/telegram/src/bot-native-commands.test.ts index e20806b11e4..f2737d98f89 100644 --- a/extensions/telegram/src/bot-native-commands.test.ts +++ b/extensions/telegram/src/bot-native-commands.test.ts @@ -9,6 +9,7 @@ import { pluginCommandMocks, resetPluginCommandMocks, } from "../../../test/helpers/extensions/telegram-plugin-command.js"; +import type { TelegramBotDeps } from "./bot-deps.js"; const skillCommandMocks = vi.hoisted(() => ({ listSkillCommandsForAgents: vi.fn(() => []), })); @@ -31,11 +32,33 @@ vi.mock("./bot/delivery.js", () => ({ import { registerTelegramNativeCommands } from "./bot-native-commands.js"; import { createCommandBot, - createNativeCommandTestParams, + createNativeCommandTestParams as createNativeCommandTestParamsBase, createPrivateCommandContext, waitForRegisteredCommands, } from "./bot-native-commands.menu-test-support.js"; +function createNativeCommandTestParams( + cfg: OpenClawConfig, + params: Partial[0]> = {}, +) { + const telegramDeps: TelegramBotDeps = { + loadConfig: vi.fn(() => ({})), + resolveStorePath: vi.fn((storePath?: string) => storePath ?? "/tmp/sessions.json"), + readChannelAllowFromStore: vi.fn(async () => []), + enqueueSystemEvent: vi.fn(), + dispatchReplyWithBufferedBlockDispatcher: vi.fn(async () => ({ + queuedFinal: false, + counts: {}, + })), + listSkillCommandsForAgents: skillCommandMocks.listSkillCommandsForAgents, + wasSentByBot: vi.fn(() => false), + }; + return createNativeCommandTestParamsBase(cfg, { + telegramDeps, + ...params, + }); +} + describe("registerTelegramNativeCommands", () => { beforeEach(() => { skillCommandMocks.listSkillCommandsForAgents.mockClear();