mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 17:40:24 +00:00
test(channels): inject telegram reply pipeline for dispatch tests
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user