Skip to content

Commit c2a13e2

Browse files
committed
test: tighten heartbeat runner assertions
1 parent 0f03af8 commit c2a13e2

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ describe("runHeartbeatOnce ack handling", () => {
370370
});
371371

372372
expect(res.status).toBe("skipped");
373-
expect(res).toMatchObject({ reason: "whatsapp-not-linked" });
373+
if (!("reason" in res)) {
374+
throw new Error("expected skipped heartbeat result reason");
375+
}
376+
expect(res.reason).toBe("whatsapp-not-linked");
374377
expect(sendWhatsApp).not.toHaveBeenCalled();
375378
});
376379
});
@@ -405,11 +408,11 @@ describe("runHeartbeatOnce ack handling", () => {
405408
});
406409

407410
expect(sendTelegram).toHaveBeenCalledTimes(1);
408-
expect(sendTelegram).toHaveBeenCalledWith(
409-
TELEGRAM_GROUP,
410-
"Hello from heartbeat",
411-
expect.objectContaining({ accountId: params.expectedAccountId, verbose: false }),
412-
);
411+
const [chatId, text, options] = sendTelegram.mock.calls[0] ?? [];
412+
expect(chatId).toBe(TELEGRAM_GROUP);
413+
expect(text).toBe("Hello from heartbeat");
414+
expect(options?.accountId).toBe(params.expectedAccountId);
415+
expect(options?.verbose).toBe(false);
413416
});
414417
}
415418

src/infra/heartbeat-runner.subagent-session-guard.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,11 @@ describe("runHeartbeatOnce", () => {
6868
});
6969

7070
expect(replySpy).toHaveBeenCalledTimes(1);
71-
expect(replySpy).toHaveBeenCalledWith(
72-
expect.objectContaining({
73-
SessionKey: mainSessionKey,
74-
OriginatingChannel: undefined,
75-
OriginatingTo: undefined,
76-
}),
77-
expect.anything(),
78-
cfg,
79-
);
71+
const [replyParams, _replyRuntime, replyConfig] = replySpy.mock.calls[0] ?? [];
72+
expect(replyParams?.SessionKey).toBe(mainSessionKey);
73+
expect(replyParams?.OriginatingChannel).toBeUndefined();
74+
expect(replyParams?.OriginatingTo).toBeUndefined();
75+
expect(replyConfig).toBe(cfg);
8076
});
8177
});
8278
});

0 commit comments

Comments
 (0)