




















@@ -1699,13 +1699,12 @@ describe("deliverOutboundPayloads", () => {
16991699});
1700170017011701expect(sendFormattedText).toHaveBeenCalledTimes(1);
1702-expect(sendFormattedText).toHaveBeenCalledWith(
1703-expect.objectContaining({
1704-to: "U123",
1705-text: "hello **boss**",
1706-accountId: "default",
1707-}),
1708-);
1702+const formattedTextOptions = sendFormattedText.mock.calls[0]?.[0] as
1703+| { accountId?: unknown; text?: unknown; to?: unknown }
1704+| undefined;
1705+expect(formattedTextOptions?.to).toBe("U123");
1706+expect(formattedTextOptions?.text).toBe("hello **boss**");
1707+expect(formattedTextOptions?.accountId).toBe("default");
17091708expect(sendText).not.toHaveBeenCalled();
17101709expect(textResults.map((entry) => entry.messageId)).toEqual([
17111710"fmt:hello **boss**:1",
@@ -1722,17 +1721,13 @@ describe("deliverOutboundPayloads", () => {
17221721});
1723172217241723expect(sendFormattedMedia).toHaveBeenCalledTimes(1);
1725-expect(sendFormattedMedia).toHaveBeenCalledWith(
1726-expect.objectContaining({
1727-to: "U123",
1728-text: "photo",
1729-mediaUrl: "file:///tmp/f.png",
1730-mediaLocalRoots: expect.arrayContaining([expectedPreferredTmpRoot]),
1731-}),
1732-);
17331724const sendFormattedMediaCall = sendFormattedMedia.mock.calls[0]?.[0] as
1734-| { mediaLocalRoots?: string[] }
1725+| { mediaLocalRoots?: string[]; mediaUrl?: unknown; text?: unknown; to?: unknown }
17351726| undefined;
1727+expect(sendFormattedMediaCall?.to).toBe("U123");
1728+expect(sendFormattedMediaCall?.text).toBe("photo");
1729+expect(sendFormattedMediaCall?.mediaUrl).toBe("file:///tmp/f.png");
1730+expect(sendFormattedMediaCall?.mediaLocalRoots).toContain(expectedPreferredTmpRoot);
17361731expect(
17371732sendFormattedMediaCall?.mediaLocalRoots?.some((root) =>
17381733root.endsWith(path.join(".openclaw", "workspace-work")),
@@ -1752,13 +1747,12 @@ describe("deliverOutboundPayloads", () => {
17521747deps: { matrix: sendMatrix },
17531748});
175417491755-expect(sendMatrix).toHaveBeenCalledWith(
1756-"!room:example",
1757-"hi",
1758-expect.objectContaining({
1759-mediaLocalRoots: expect.arrayContaining([expectedPreferredTmpRoot]),
1760-}),
1761-);
1750+expect(sendMatrix.mock.calls[0]?.[0]).toBe("!room:example");
1751+expect(sendMatrix.mock.calls[0]?.[1]).toBe("hi");
1752+const sendMatrixOptions = sendMatrix.mock.calls[0]?.[2] as
1753+| { mediaLocalRoots?: string[] }
1754+| undefined;
1755+expect(sendMatrixOptions?.mediaLocalRoots).toContain(expectedPreferredTmpRoot);
17621756});
1763175717641758it("sends plugin media to an explicit target once instead of fanning out over allowFrom", async () => {
@@ -1795,14 +1789,23 @@ describe("deliverOutboundPayloads", () => {
17951789});
1796179017971791expect(sendMedia).toHaveBeenCalledTimes(1);
1798-expect(sendMedia).toHaveBeenCalledWith(
1799-expect.objectContaining({
1800-to: "!explicit:example",
1801-text: "HEARTBEAT_OK",
1802-mediaUrl: "https://example.com/img.png",
1803-accountId: undefined,
1804-}),
1805-);
1792+const sendMediaOptions = (
1793+sendMedia.mock.calls as Array<
1794+[
1795+{
1796+accountId?: unknown;
1797+audioAsVoice?: unknown;
1798+mediaUrl?: unknown;
1799+text?: unknown;
1800+to?: unknown;
1801+},
1802+]
1803+>
1804+)[0]?.[0];
1805+expect(sendMediaOptions?.to).toBe("!explicit:example");
1806+expect(sendMediaOptions?.text).toBe("HEARTBEAT_OK");
1807+expect(sendMediaOptions?.mediaUrl).toBe("https://example.com/img.png");
1808+expect(sendMediaOptions?.accountId).toBeUndefined();
18061809});
1807181018081811it("forwards audioAsVoice through generic plugin media delivery", async () => {
@@ -1838,14 +1841,15 @@ describe("deliverOutboundPayloads", () => {
18381841payloads: [{ text: "voice caption", mediaUrl: "file:///tmp/clip.mp3", audioAsVoice: true }],
18391842});
184018431841-expect(sendMedia).toHaveBeenCalledWith(
1842-expect.objectContaining({
1843-to: "room:!room:example",
1844-text: "voice caption",
1845-mediaUrl: "file:///tmp/clip.mp3",
1846-audioAsVoice: true,
1847-}),
1848-);
1844+const sendMediaOptions = (
1845+sendMedia.mock.calls as unknown as Array<
1846+[{ audioAsVoice?: unknown; mediaUrl?: unknown; text?: unknown; to?: unknown }]
1847+>
1848+)[0]?.[0];
1849+expect(sendMediaOptions?.to).toBe("room:!room:example");
1850+expect(sendMediaOptions?.text).toBe("voice caption");
1851+expect(sendMediaOptions?.mediaUrl).toBe("file:///tmp/clip.mp3");
1852+expect(sendMediaOptions?.audioAsVoice).toBe(true);
18491853});
1850185418511855it("exposes audio-only spokenText to hooks without rendering it as media caption", async () => {
@@ -1888,26 +1892,25 @@ describe("deliverOutboundPayloads", () => {
18881892],
18891893});
189018941891-expect(hookMocks.runner.runMessageSending).toHaveBeenCalledWith(
1892-expect.objectContaining({
1893-content: "original hidden transcript",
1894-}),
1895-expect.objectContaining({ channelId: "matrix" }),
1896-);
1897-expect(sendMedia).toHaveBeenCalledWith(
1898-expect.objectContaining({
1899-text: "",
1900-mediaUrl: "file:///tmp/clip.opus",
1901-audioAsVoice: true,
1902-}),
1903-);
1904-expect(hookMocks.runner.runMessageSent).toHaveBeenCalledWith(
1905-expect.objectContaining({
1906-content: "rewritten hidden transcript",
1907-success: true,
1908-}),
1909-expect.objectContaining({ channelId: "matrix" }),
1910-);
1895+const sendingCall = hookMocks.runner.runMessageSending.mock.calls[0] as
1896+| [{ content?: unknown }, { channelId?: unknown }]
1897+| undefined;
1898+expect(sendingCall?.[0]?.content).toBe("original hidden transcript");
1899+expect(sendingCall?.[1]?.channelId).toBe("matrix");
1900+const sendMediaOptions = (
1901+sendMedia.mock.calls as unknown as Array<
1902+[{ audioAsVoice?: unknown; mediaUrl?: unknown; text?: unknown }]
1903+>
1904+)[0]?.[0];
1905+expect(sendMediaOptions?.text).toBe("");
1906+expect(sendMediaOptions?.mediaUrl).toBe("file:///tmp/clip.opus");
1907+expect(sendMediaOptions?.audioAsVoice).toBe(true);
1908+const sentCall = hookMocks.runner.runMessageSent.mock.calls[0] as
1909+| [{ content?: unknown; success?: unknown }, { channelId?: unknown }]
1910+| undefined;
1911+expect(sentCall?.[0]?.content).toBe("rewritten hidden transcript");
1912+expect(sentCall?.[0]?.success).toBe(true);
1913+expect(sentCall?.[1]?.channelId).toBe("matrix");
19111914});
1912191519131916it("chunks plugin text and returns all results", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。