mirror of https://github.com/openclaw/openclaw.git
test: merge channel reply pipeline typing cases
This commit is contained in:
parent
7ae093cf0f
commit
098125e998
|
|
@ -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?.();
|
||||
|
|
|
|||
Loading…
Reference in New Issue