test: merge channel reply pipeline typing cases

This commit is contained in:
Peter Steinberger 2026-04-01 03:26:24 +01:00
parent 7ae093cf0f
commit 098125e998
No known key found for this signature in database
1 changed files with 45 additions and 23 deletions

View File

@ -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?.();