test(ci): isolate cron heartbeat delivery cases

This commit is contained in:
Peter Steinberger 2026-03-14 06:28:51 +00:00
parent 61bf7b8536
commit 17cb60080a
1 changed files with 23 additions and 7 deletions

View File

@ -138,11 +138,10 @@ describe("runCronIsolatedAgentTurn", () => {
}); });
}); });
it("handles media heartbeat delivery and last-target text delivery", async () => { it("delivers media payloads even when heartbeat text is suppressed", async () => {
await withTempHome(async (home) => { await withTempHome(async (home) => {
const { storePath, deps } = await createTelegramDeliveryFixture(home); const { storePath, deps } = await createTelegramDeliveryFixture(home);
// Media should still be delivered even if text is just HEARTBEAT_OK.
mockEmbeddedAgentPayloads([ mockEmbeddedAgentPayloads([
{ text: "HEARTBEAT_OK", mediaUrl: "https://example.com/img.png" }, { text: "HEARTBEAT_OK", mediaUrl: "https://example.com/img.png" },
]); ]);
@ -156,9 +155,13 @@ describe("runCronIsolatedAgentTurn", () => {
expect(mediaRes.status).toBe("ok"); expect(mediaRes.status).toBe("ok");
expect(deps.sendMessageTelegram).toHaveBeenCalled(); expect(deps.sendMessageTelegram).toHaveBeenCalled();
expect(runSubagentAnnounceFlow).not.toHaveBeenCalled(); expect(runSubagentAnnounceFlow).not.toHaveBeenCalled();
});
});
it("keeps non-empty heartbeat text when last-target ack suppression is disabled", async () => {
await withTempHome(async (home) => {
const { storePath, deps } = await createTelegramDeliveryFixture(home);
vi.mocked(runSubagentAnnounceFlow).mockClear();
vi.mocked(deps.sendMessageTelegram).mockClear();
mockEmbeddedAgentPayloads([{ text: "HEARTBEAT_OK 🦞" }]); mockEmbeddedAgentPayloads([{ text: "HEARTBEAT_OK 🦞" }]);
const cfg = makeCfg(home, storePath); const cfg = makeCfg(home, storePath);
@ -194,10 +197,23 @@ describe("runCronIsolatedAgentTurn", () => {
"HEARTBEAT_OK 🦞", "HEARTBEAT_OK 🦞",
expect.objectContaining({ accountId: undefined }), expect.objectContaining({ accountId: undefined }),
); );
});
});
vi.mocked(deps.sendMessageTelegram).mockClear(); it("deletes the direct cron session after last-target text delivery", async () => {
vi.mocked(runSubagentAnnounceFlow).mockClear(); await withTempHome(async (home) => {
vi.mocked(callGateway).mockClear(); const { storePath, deps } = await createTelegramDeliveryFixture(home);
mockEmbeddedAgentPayloads([{ text: "HEARTBEAT_OK 🦞" }]);
const cfg = makeCfg(home, storePath);
cfg.agents = {
...cfg.agents,
defaults: {
...cfg.agents?.defaults,
heartbeat: { ackMaxChars: 0 },
},
};
const deleteRes = await runCronIsolatedAgentTurn({ const deleteRes = await runCronIsolatedAgentTurn({
cfg, cfg,