test: update health/status and legacy migration coverage

This commit is contained in:
Peter Steinberger
2026-01-17 01:14:06 +00:00
parent f14d622c0f
commit c592f395df
7 changed files with 305 additions and 25 deletions

View File

@@ -30,10 +30,6 @@ vi.mock("../web/auth-store.js", () => ({
logWebSelfId: vi.fn(),
}));
vi.mock("../web/reconnect.js", () => ({
resolveHeartbeatSeconds: vi.fn(() => 60),
}));
describe("getHealthSnapshot", () => {
afterEach(() => {
vi.unstubAllGlobals();
@@ -229,4 +225,32 @@ describe("getHealthSnapshot", () => {
expect(telegram.probe?.ok).toBe(false);
expect(telegram.probe?.error).toMatch(/network down/i);
});
it("disables heartbeat for agents without heartbeat blocks", async () => {
testConfig = {
agents: {
defaults: {
heartbeat: {
every: "30m",
target: "last",
},
},
list: [
{ id: "main", default: true },
{ id: "ops", heartbeat: { every: "1h", target: "whatsapp" } },
],
},
};
testStore = {};
const snap = await getHealthSnapshot({ timeoutMs: 10, probe: false });
const byAgent = new Map(snap.agents.map((agent) => [agent.agentId, agent] as const));
const main = byAgent.get("main");
const ops = byAgent.get("ops");
expect(main?.heartbeat.everyMs).toBeNull();
expect(main?.heartbeat.every).toBe("disabled");
expect(ops?.heartbeat.everyMs).toBeTruthy();
expect(ops?.heartbeat.every).toBe("1h");
});
});