
















@@ -81,6 +81,15 @@ function expectReply(
8181return handled.reply;
8282}
838384+function lastMockCall(mock: { mock: { calls: unknown[][] } }, label: string): unknown[] {
85+const calls = mock.mock.calls;
86+const call = calls[calls.length - 1];
87+if (!call) {
88+throw new Error(`expected ${label} call`);
89+}
90+return call;
91+}
92+8493describe("handleTtsCommands status fallback reporting", () => {
8594beforeEach(() => {
8695vi.clearAllMocks();
@@ -224,10 +233,11 @@ describe("handleTtsCommands status fallback reporting", () => {
224233const result = await handleTtsCommands(buildTtsParams("/tts status", cfg, "reader"), true);
225234226235expectHandled(result);
227-const resolveCall = ttsMocks.resolveTtsConfig.mock.calls.at(-1);
228-expect(resolveCall?.[0]).toBe(cfg);
229-expect(resolveCall?.[1]?.agentId).toBe("reader");
230-expect(resolveCall?.[1]?.channelId).toBe("forum");
236+const resolveCall = lastMockCall(ttsMocks.resolveTtsConfig, "resolveTtsConfig");
237+const resolveOptions = resolveCall[1] as { agentId?: string; channelId?: string };
238+expect(resolveCall[0]).toBe(cfg);
239+expect(resolveOptions.agentId).toBe("reader");
240+expect(resolveOptions.channelId).toBe("forum");
231241});
232242233243it("passes the active agent and account ids to /tts audio synthesis", async () => {
@@ -249,11 +259,16 @@ describe("handleTtsCommands status fallback reporting", () => {
249259);
250260251261expectHandled(result);
252-const speechCall = ttsMocks.textToSpeech.mock.calls.at(-1)?.[0];
253-expect(speechCall?.text).toBe("hello");
254-expect(speechCall?.cfg).toBe(cfg);
255-expect(speechCall?.agentId).toBe("reader");
256-expect(speechCall?.accountId).toBe("feishu-main");
262+const speechCall = lastMockCall(ttsMocks.textToSpeech, "textToSpeech")[0] as {
263+accountId?: string;
264+agentId?: string;
265+cfg?: OpenClawConfig;
266+text?: string;
267+};
268+expect(speechCall.text).toBe("hello");
269+expect(speechCall.cfg).toBe(cfg);
270+expect(speechCall.agentId).toBe("reader");
271+expect(speechCall.accountId).toBe("feishu-main");
257272});
258273259274it("lists and sets configured TTS personas", async () => {
@@ -333,7 +348,10 @@ describe("handleTtsCommands status fallback reporting", () => {
333348expect(reply.mediaUrl).toBe("/tmp/latest.ogg");
334349expect(reply.audioAsVoice).toBe(true);
335350expect(reply.spokenText).toBe("latest visible reply");
336-expect(ttsMocks.textToSpeech.mock.calls.at(-1)?.[0]?.text).toBe("latest visible reply");
351+const speechCall = lastMockCall(ttsMocks.textToSpeech, "textToSpeech")[0] as {
352+text?: string;
353+};
354+expect(speechCall.text).toBe("latest visible reply");
337355expect(sessionEntry.lastTtsReadLatestHash).toMatch(/^[a-f0-9]{64}$/);
338356expect(sessionEntry.lastTtsReadLatestAt).toBeGreaterThanOrEqual(beforeTtsRead);
339357});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。