From 098125e9982b712e129c4896891cc2e48ef2485a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 1 Apr 2026 03:26:24 +0100 Subject: [PATCH] test: merge channel reply pipeline typing cases --- src/plugin-sdk/channel-reply-pipeline.test.ts | 68 ++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/src/plugin-sdk/channel-reply-pipeline.test.ts b/src/plugin-sdk/channel-reply-pipeline.test.ts index ae94736df3d..68c5ed42d3a 100644 --- a/src/plugin-sdk/channel-reply-pipeline.test.ts +++ b/src/plugin-sdk/channel-reply-pipeline.test.ts @@ -2,33 +2,55 @@ import { describe, expect, it, vi } from "vitest"; import { createChannelReplyPipeline } from "./channel-reply-pipeline.js"; describe("createChannelReplyPipeline", () => { - it("builds prefix options without forcing typing support", () => { - const pipeline = createChannelReplyPipeline({ - cfg: {}, - agentId: "main", - channel: "telegram", - accountId: "default", - }); + it.each([ + { + name: "builds prefix options without forcing typing support", + input: { + cfg: {}, + agentId: "main", + channel: "telegram", + accountId: "default", + }, + expectTypingCallbacks: false, + }, + { + name: "builds typing callbacks when typing config is provided", + input: { + cfg: {}, + agentId: "main", + channel: "discord", + accountId: "default", + typing: { + start: vi.fn(async () => {}), + stop: vi.fn(async () => {}), + onStartError: () => {}, + }, + }, + expectTypingCallbacks: true, + }, + ])("$name", async ({ input, expectTypingCallbacks }) => { + const start = vi.fn(async () => {}); + const stop = vi.fn(async () => {}); + const pipeline = createChannelReplyPipeline( + expectTypingCallbacks + ? { + ...input, + typing: { + start, + stop, + onStartError: () => {}, + }, + } + : input, + ); expect(typeof pipeline.onModelSelected).toBe("function"); expect(typeof pipeline.responsePrefixContextProvider).toBe("function"); - expect(pipeline.typingCallbacks).toBeUndefined(); - }); - it("builds typing callbacks when typing config is provided", async () => { - const start = vi.fn(async () => {}); - const stop = vi.fn(async () => {}); - const pipeline = createChannelReplyPipeline({ - cfg: {}, - agentId: "main", - channel: "discord", - accountId: "default", - typing: { - start, - stop, - onStartError: () => {}, - }, - }); + if (!expectTypingCallbacks) { + expect(pipeline.typingCallbacks).toBeUndefined(); + return; + } await pipeline.typingCallbacks?.onReplyStart(); pipeline.typingCallbacks?.onIdle?.();