test(cron): relax event assertions for context keys

This commit is contained in:
Peter Steinberger
2026-02-15 03:53:49 +00:00
parent f1a76e1a36
commit 9db2ebed00
6 changed files with 52 additions and 27 deletions

View File

@@ -72,7 +72,10 @@ describe("CronService interval/cron jobs fire on time", () => {
const jobs = await cron.list({ includeDisabled: true });
const updated = jobs.find((current) => current.id === job.id);
expect(enqueueSystemEvent).toHaveBeenCalledWith("tick", { agentId: undefined });
expect(enqueueSystemEvent).toHaveBeenCalledWith(
"tick",
expect.objectContaining({ agentId: undefined }),
);
expect(updated?.state.lastStatus).toBe("ok");
// nextRunAtMs must advance by at least one full interval past the due time.
expect(updated?.state.nextRunAtMs).toBeGreaterThanOrEqual(firstDueAt + 10_000);
@@ -120,7 +123,10 @@ describe("CronService interval/cron jobs fire on time", () => {
const jobs = await cron.list({ includeDisabled: true });
const updated = jobs.find((current) => current.id === job.id);
expect(enqueueSystemEvent).toHaveBeenCalledWith("cron-tick", { agentId: undefined });
expect(enqueueSystemEvent).toHaveBeenCalledWith(
"cron-tick",
expect.objectContaining({ agentId: undefined }),
);
expect(updated?.state.lastStatus).toBe("ok");
// nextRunAtMs should be the next whole-minute boundary (60s later).
expect(updated?.state.nextRunAtMs).toBe(firstDueAt + 60_000);