mirror of https://github.com/openclaw/openclaw.git
test(ci): isolate cron heartbeat delivery cases
This commit is contained in:
parent
61bf7b8536
commit
17cb60080a
|
|
@ -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) => {
|
||||
const { storePath, deps } = await createTelegramDeliveryFixture(home);
|
||||
|
||||
// Media should still be delivered even if text is just HEARTBEAT_OK.
|
||||
mockEmbeddedAgentPayloads([
|
||||
{ text: "HEARTBEAT_OK", mediaUrl: "https://example.com/img.png" },
|
||||
]);
|
||||
|
|
@ -156,9 +155,13 @@ describe("runCronIsolatedAgentTurn", () => {
|
|||
expect(mediaRes.status).toBe("ok");
|
||||
expect(deps.sendMessageTelegram).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 🦞" }]);
|
||||
|
||||
const cfg = makeCfg(home, storePath);
|
||||
|
|
@ -194,10 +197,23 @@ describe("runCronIsolatedAgentTurn", () => {
|
|||
"HEARTBEAT_OK 🦞",
|
||||
expect.objectContaining({ accountId: undefined }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
vi.mocked(deps.sendMessageTelegram).mockClear();
|
||||
vi.mocked(runSubagentAnnounceFlow).mockClear();
|
||||
vi.mocked(callGateway).mockClear();
|
||||
it("deletes the direct cron session after last-target text delivery", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
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({
|
||||
cfg,
|
||||
|
|
|
|||
Loading…
Reference in New Issue