

























@@ -25,6 +25,8 @@ vi.mock("../utils/message-channel.js", () => ({
25252626import { DEFAULT_ECHO_TRANSCRIPT_FORMAT, sendTranscriptEcho } from "./echo-transcript.js";
272728+const EMPTY_CONFIG = {} as OpenClawConfig;
29+2830function createCtx(overrides?: Partial<MsgContext>): MsgContext {
2931return {
3032Provider: "voicechat",
@@ -47,44 +49,47 @@ describe("sendTranscriptEcho", () => {
4749it("sends the default formatted transcript to the resolved origin", async () => {
4850await sendTranscriptEcho({
4951ctx: createCtx(),
50-cfg: {} as OpenClawConfig,
52+cfg: EMPTY_CONFIG,
5153transcript: "hello world",
5254});
53555456expect(mockDeliverOutboundPayloads).toHaveBeenCalledOnce();
55-expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith(
56-expect.objectContaining({
57-cfg: {},
58-channel: "voicechat",
59-to: "+10000000001",
60-accountId: "acc1",
61-threadId: undefined,
62-payloads: [{ text: DEFAULT_ECHO_TRANSCRIPT_FORMAT.replace("{transcript}", "hello world") }],
63-bestEffort: true,
64-durability: "best_effort",
65-}),
66-);
57+expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith({
58+cfg: EMPTY_CONFIG,
59+channel: "voicechat",
60+to: "+10000000001",
61+accountId: "acc1",
62+threadId: undefined,
63+payloads: [{ text: DEFAULT_ECHO_TRANSCRIPT_FORMAT.replace("{transcript}", "hello world") }],
64+bestEffort: true,
65+durability: "best_effort",
66+});
6767});
68686969it("uses a custom format when provided", async () => {
7070await sendTranscriptEcho({
7171ctx: createCtx(),
72-cfg: {} as OpenClawConfig,
72+cfg: EMPTY_CONFIG,
7373transcript: "custom message",
7474format: "🎙️ Heard: {transcript}",
7575});
767677-expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith(
78-expect.objectContaining({
79-payloads: [{ text: "🎙️ Heard: custom message" }],
80-}),
81-);
77+expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith({
78+cfg: EMPTY_CONFIG,
79+channel: "voicechat",
80+to: "+10000000001",
81+accountId: "acc1",
82+threadId: undefined,
83+payloads: [{ text: "🎙️ Heard: custom message" }],
84+bestEffort: true,
85+durability: "best_effort",
86+});
8287});
83888489it("skips non-deliverable channels", async () => {
8590await sendTranscriptEcho({
8691ctx: createCtx({ Provider: "internal-system", From: "some-source" }),
87-cfg: {} as OpenClawConfig,
92+cfg: EMPTY_CONFIG,
8893transcript: "hello world",
8994});
9095@@ -94,7 +99,7 @@ describe("sendTranscriptEcho", () => {
9499it("skips when ctx has no resolved destination", async () => {
95100await sendTranscriptEcho({
96101ctx: createCtx({ From: undefined, OriginatingTo: undefined }),
97-cfg: {} as OpenClawConfig,
102+cfg: EMPTY_CONFIG,
98103transcript: "hello world",
99104});
100105@@ -104,15 +109,20 @@ describe("sendTranscriptEcho", () => {
104109it("prefers OriginatingTo when From is absent", async () => {
105110await sendTranscriptEcho({
106111ctx: createCtx({ From: undefined, OriginatingTo: "+19999999999" }),
107-cfg: {} as OpenClawConfig,
112+cfg: EMPTY_CONFIG,
108113transcript: "hello world",
109114});
110115111-expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith(
112-expect.objectContaining({
113-to: "+19999999999",
114-}),
115-);
116+expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith({
117+cfg: EMPTY_CONFIG,
118+channel: "voicechat",
119+to: "+19999999999",
120+accountId: "acc1",
121+threadId: undefined,
122+payloads: [{ text: DEFAULT_ECHO_TRANSCRIPT_FORMAT.replace("{transcript}", "hello world") }],
123+bestEffort: true,
124+durability: "best_effort",
125+});
116126});
117127118128it("forwards Telegram account and thread metadata to outbound delivery", async () => {
@@ -124,21 +134,22 @@ describe("sendTranscriptEcho", () => {
124134AccountId: "primary",
125135MessageThreadId: 77,
126136}),
127-cfg: {} as OpenClawConfig,
137+cfg: EMPTY_CONFIG,
128138transcript: "threaded voice note",
129139});
130140131-expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith(
132-expect.objectContaining({
133-channel: "telegram",
134-to: "telegram:42",
135-accountId: "primary",
136-threadId: 77,
137-payloads: [
138-{ text: DEFAULT_ECHO_TRANSCRIPT_FORMAT.replace("{transcript}", "threaded voice note") },
139-],
140-}),
141-);
141+expect(mockDeliverOutboundPayloads).toHaveBeenCalledWith({
142+cfg: EMPTY_CONFIG,
143+channel: "telegram",
144+to: "telegram:42",
145+accountId: "primary",
146+threadId: 77,
147+payloads: [
148+{ text: DEFAULT_ECHO_TRANSCRIPT_FORMAT.replace("{transcript}", "threaded voice note") },
149+],
150+bestEffort: true,
151+durability: "best_effort",
152+});
142153});
143154144155it("swallows delivery failures", async () => {
@@ -147,7 +158,7 @@ describe("sendTranscriptEcho", () => {
147158await expect(
148159sendTranscriptEcho({
149160ctx: createCtx(),
150-cfg: {} as OpenClawConfig,
161+cfg: EMPTY_CONFIG,
151162transcript: "hello world",
152163}),
153164).resolves.toBeUndefined();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。