test(channels): inject telegram reply pipeline for dispatch tests

This commit is contained in:
Vincent Koc
2026-03-31 20:53:57 +09:00
parent 5474796735
commit 334085fbe9
4 changed files with 22 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
import { enqueueSystemEvent } from "openclaw/plugin-sdk/channel-runtime";
import {
buildModelsProviderData,
@@ -34,6 +35,7 @@ export type TelegramBotDeps = {
deliverReplies?: typeof deliverReplies;
emitInternalMessageSentHook?: typeof emitInternalMessageSentHook;
editMessageTelegram?: typeof editMessageTelegram;
createChannelReplyPipeline?: typeof createChannelReplyPipeline;
};
export const defaultTelegramBotDeps: TelegramBotDeps = {
@@ -88,4 +90,7 @@ export const defaultTelegramBotDeps: TelegramBotDeps = {
get editMessageTelegram() {
return editMessageTelegram;
},
get createChannelReplyPipeline() {
return createChannelReplyPipeline;
},
};

View File

@@ -42,6 +42,14 @@ const buildModelsProviderData = vi.hoisted(() =>
})),
);
const listSkillCommandsForAgents = vi.hoisted(() => vi.fn(() => []));
const createChannelReplyPipeline = vi.hoisted(() =>
vi.fn(() => ({
responsePrefix: undefined,
enableSlackInteractiveReplies: undefined,
responsePrefixContextProvider: () => ({ identityName: undefined }),
onModelSelected: () => undefined,
})),
);
const wasSentByBot = vi.hoisted(() => vi.fn(() => false));
const loadSessionStore = vi.hoisted(() => vi.fn());
const resolveStorePath = vi.hoisted(() => vi.fn(() => "/tmp/sessions.json"));
@@ -115,6 +123,8 @@ const telegramDepsForTest: TelegramBotDeps = {
buildModelsProviderData: buildModelsProviderData as TelegramBotDeps["buildModelsProviderData"],
listSkillCommandsForAgents:
listSkillCommandsForAgents as TelegramBotDeps["listSkillCommandsForAgents"],
createChannelReplyPipeline:
createChannelReplyPipeline as TelegramBotDeps["createChannelReplyPipeline"],
wasSentByBot: wasSentByBot as TelegramBotDeps["wasSentByBot"],
createTelegramDraftStream:
createTelegramDraftStream as TelegramBotDeps["createTelegramDraftStream"],
@@ -150,6 +160,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
enqueueSystemEvent.mockClear();
buildModelsProviderData.mockClear();
listSkillCommandsForAgents.mockClear();
createChannelReplyPipeline.mockClear();
wasSentByBot.mockClear();
loadSessionStore.mockClear();
resolveStorePath.mockClear();

View File

@@ -570,7 +570,9 @@ export const dispatchTelegramMessage = async ({
void statusReactionController.setThinking();
}
const { onModelSelected, ...replyPipeline } = createChannelReplyPipeline({
const { onModelSelected, ...replyPipeline } = (
telegramDeps.createChannelReplyPipeline ?? createChannelReplyPipeline
)({
cfg,
agentId: route.agentId,
channel: "telegram",