























1-// Channel Message Flows tests cover channel message flows script behavior.
1+// Channel Message Flows tests cover QA Lab channel delivery evidence.
2+import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
23import { describe, expect, it, vi } from "vitest";
34import {
4-parseChannelMessageFlowArgs,
55resolveTelegramFlowThreadSpec,
66runTelegramThinkingFinalFlow,
77runTelegramWorkingFinalFlow,
8-} from "../../scripts/dev/channel-message-flows.ts";
9-import type { OpenClawConfig } from "../../src/config/types.openclaw.js";
8+} from "./test-support/channel-message-flows.js";
10911-describe("channel message flows dev runner", () => {
10+describe("channel message flows QA e2e", () => {
1211function createTestDraftStream(params?: {
1312update?: (text: string) => void;
1413flush?: () => Promise<void>;
1514clear?: () => Promise<void>;
1615}) {
1716return {
1817update: vi.fn(params?.update ?? (() => {})),
18+updatePreview: vi.fn(),
1919flush: vi.fn(params?.flush ?? (async () => {})),
2020clear: vi.fn(params?.clear ?? (async () => {})),
2121stop: vi.fn(async () => {}),
@@ -24,55 +24,6 @@ describe("channel message flows dev runner", () => {
2424};
2525}
262627-it("parses the Telegram thinking-final flow from channel/target flags", () => {
28-const parsed = parseChannelMessageFlowArgs([
29-"--channel",
30-"telegram",
31-"--target",
32-"123",
33-"--flow",
34-"thinking-final",
35-"--account",
36-"sut",
37-"--thread-id",
38-"42",
39-"--delay-ms",
40-"0",
41-]);
42-43-expect(parsed).toEqual({
44-accountId: "sut",
45-channel: "telegram",
46-delayMs: 0,
47-flow: "thinking-final",
48-target: "123",
49-threadId: 42,
50-});
51-});
52-53-it("parses the Telegram working-final flow from channel/chat flags", () => {
54-const parsed = parseChannelMessageFlowArgs([
55-"--channel",
56-"telegram",
57-"--chat",
58-"123",
59-"--flow",
60-"working-final",
61-"--duration-ms",
62-"12000",
63-"--delay-ms",
64-"0",
65-]);
66-67-expect(parsed).toEqual({
68-channel: "telegram",
69-delayMs: 0,
70-durationMs: 12000,
71-flow: "working-final",
72-target: "123",
73-});
74-});
75-7627it("streams thinking updates, clears the preview, then sends the final answer", async () => {
7728const events: string[] = [];
7829const stream = {
@@ -85,6 +36,7 @@ describe("channel message flows dev runner", () => {
8536clear: vi.fn(async () => {
8637events.push("clear");
8738}),
39+updatePreview: vi.fn(),
8840stop: vi.fn(async () => {}),
8941messageId: vi.fn(() => 17),
9042forceNewMessage: vi.fn(),
@@ -96,9 +48,11 @@ describe("channel message flows dev runner", () => {
96489749const result = await runTelegramThinkingFinalFlow(
9850{
51+accountId: "sut",
9952cfg: {} as OpenClawConfig,
10053delayMs: 0,
10154target: "123",
55+threadId: 42,
10256thinkingUpdates: ["Checking the request.", "Reading the Telegram code.", "Ready."],
10357},
10458{
@@ -114,11 +68,11 @@ describe("channel message flows dev runner", () => {
11468expect(events.at(-2)).toBe("clear");
11569expect(events.at(-1)).toBe("final");
11670expect(sendFinal).toHaveBeenCalledWith({
117-accountId: undefined,
71+accountId: "sut",
11872cfg: {},
11973target: "123",
12074text: "Final answer: the Telegram thinking preview cleared and this durable reply landed.",
121-threadId: undefined,
75+threadId: 42,
12276});
12377expect(result).toEqual({ finalMessageId: "99", previewUpdates: 3 });
12478});
@@ -130,6 +84,7 @@ describe("channel message flows dev runner", () => {
13084throw new Error("flush failed");
13185}),
13286clear: vi.fn(async () => {}),
87+updatePreview: vi.fn(),
13388stop: vi.fn(async () => {}),
13489messageId: vi.fn(() => 17),
13590forceNewMessage: vi.fn(),
@@ -161,6 +116,7 @@ describe("channel message flows dev runner", () => {
161116update: vi.fn(() => {}),
162117flush: vi.fn(async () => {}),
163118clear: vi.fn(async () => {}),
119+updatePreview: vi.fn(),
164120stop: vi.fn(async () => {}),
165121messageId: vi.fn(() => 17),
166122forceNewMessage: vi.fn(),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。