























@@ -76,6 +76,53 @@ describe("runHeartbeatOnce ack handling", () => {
7676});
7777}
787879+function expectTelegramMessageSend(
80+send: ReturnType<typeof vi.fn>,
81+params: { to: string; text: string; cfg: OpenClawConfig },
82+) {
83+expect(send.mock.calls).toEqual([
84+[
85+params.to,
86+params.text,
87+{
88+verbose: false,
89+cfg: params.cfg,
90+accountId: undefined,
91+},
92+],
93+]);
94+}
95+96+function expectWhatsAppMessageSend(
97+send: ReturnType<typeof vi.fn>,
98+params: { to: string; text: string; cfg: OpenClawConfig },
99+) {
100+expect(send.mock.calls).toEqual([
101+[
102+params.to,
103+params.text,
104+{
105+verbose: false,
106+cfg: params.cfg,
107+accountId: undefined,
108+audioAsVoice: undefined,
109+forceDocument: undefined,
110+formatting: undefined,
111+gatewayClientScopes: undefined,
112+gifPlayback: undefined,
113+identity: undefined,
114+kind: "text",
115+mediaAccess: {},
116+mediaLocalRoots: undefined,
117+mediaReadFile: undefined,
118+replyToIdSource: undefined,
119+replyToMode: undefined,
120+silent: undefined,
121+},
122+],
123+]);
124+}
125+79126async function runTelegramHeartbeatWithDefaults(params: {
80127tmpDir: string;
81128storePath: string;
@@ -114,7 +161,7 @@ describe("runHeartbeatOnce ack handling", () => {
114161getReplyFromConfig: params.replySpy,
115162},
116163});
117-return sendTelegram;
164+return { sendTelegram, cfg };
118165}
119166120167function createWhatsAppHeartbeatConfig(params: {
@@ -209,8 +256,11 @@ describe("runHeartbeatOnce ack handling", () => {
209256},
210257});
211258212-expect(sendWhatsApp).toHaveBeenCalledTimes(1);
213-expect(sendWhatsApp).toHaveBeenCalledWith(WHATSAPP_GROUP, "HEARTBEAT_OK", expect.any(Object));
259+expectWhatsAppMessageSend(sendWhatsApp, {
260+to: WHATSAPP_GROUP,
261+text: "HEARTBEAT_OK",
262+ cfg,
263+});
214264});
215265});
216266@@ -235,7 +285,7 @@ describe("runHeartbeatOnce ack handling", () => {
235285},
236286])("$title", async ({ replyText, messages, expectedCalls, expectedText }) => {
237287await withTempTelegramHeartbeatSandbox(async ({ tmpDir, storePath, replySpy }) => {
238-const sendTelegram = await runTelegramHeartbeatWithDefaults({
288+const { sendTelegram, cfg } = await runTelegramHeartbeatWithDefaults({
239289 tmpDir,
240290 storePath,
241291 replySpy,
@@ -245,7 +295,11 @@ describe("runHeartbeatOnce ack handling", () => {
245295246296expect(sendTelegram).toHaveBeenCalledTimes(expectedCalls);
247297if (expectedText) {
248-expect(sendTelegram).toHaveBeenCalledWith(TELEGRAM_GROUP, expectedText, expect.any(Object));
298+expectTelegramMessageSend(sendTelegram, {
299+to: TELEGRAM_GROUP,
300+text: expectedText,
301+ cfg,
302+});
249303}
250304});
251305});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。