test: clarify cron job accepted paths

This commit is contained in:
Peter Steinberger
2026-05-08 12:27:33 +01:00
parent 6abfb66aa5
commit 8caef5d0ea

View File

@@ -59,7 +59,7 @@ describe("applyJobPatch", () => {
to: "123",
});
expect(() => applyJobPatch(job, switchToMainPatch())).not.toThrow();
applyJobPatch(job, switchToMainPatch());
expect(job.sessionTarget).toBe("main");
expect(job.payload.kind).toBe("systemEvent");
expect(job.delivery).toBeUndefined();
@@ -71,7 +71,7 @@ describe("applyJobPatch", () => {
to: "https://example.invalid/cron",
});
expect(() => applyJobPatch(job, switchToMainPatch())).not.toThrow();
applyJobPatch(job, switchToMainPatch());
expect(job.sessionTarget).toBe("main");
expect(job.delivery).toEqual({ mode: "webhook", to: "https://example.invalid/cron" });
});
@@ -92,7 +92,7 @@ describe("applyJobPatch", () => {
},
};
expect(() => applyJobPatch(job, patch)).not.toThrow();
applyJobPatch(job, patch);
expect(job.payload.kind).toBe("agentTurn");
if (job.payload.kind === "agentTurn") {
expect(job.payload.message).toBe("do it");
@@ -391,7 +391,7 @@ describe("applyJobPatch", () => {
to: " https://example.invalid/failure ",
},
};
expect(() => applyJobPatch(job, { enabled: true })).not.toThrow();
applyJobPatch(job, { enabled: true });
expect(job.delivery?.failureDestination?.to).toBe("https://example.invalid/failure");
});
@@ -402,7 +402,7 @@ describe("applyJobPatch", () => {
to: "-10012345/6789",
});
expect(() => applyJobPatch(job, { enabled: true })).not.toThrow();
applyJobPatch(job, { enabled: true });
expect(job.delivery?.to).toBe("-10012345/6789");
});
@@ -421,7 +421,8 @@ describe("applyJobPatch", () => {
...(to ? { to } : {}),
});
expect(() => applyJobPatch(job, { enabled: true })).not.toThrow();
applyJobPatch(job, { enabled: true });
expect(job.enabled).toBe(true);
});
});
@@ -453,7 +454,8 @@ describe("createJob rejects sessionTarget main for non-default agents", () => {
{ name: "case-insensitive defaultAgentId match", defaultAgentId: "Main", agentId: "MAIN" },
] as const)("allows creating a main-session job for $name", ({ defaultAgentId, agentId }) => {
const state = createMockState(now, { defaultAgentId });
expect(() => createJob(state, mainJobInput(agentId))).not.toThrow();
const job = createJob(state, mainJobInput(agentId));
expect(job.sessionTarget).toBe("main");
});
it.each([
@@ -544,7 +546,8 @@ describe("applyJobPatch rejects sessionTarget main for non-default agents", () =
);
return;
}
expect(() => applyJobPatch(job, patch, { defaultAgentId: "main" })).not.toThrow();
applyJobPatch(job, patch, { defaultAgentId: "main" });
expect(job.agentId).toBe("main");
});
it("rejects patching to a custom session target with path separators", () => {
@@ -941,7 +944,7 @@ describe("recomputeNextRuns", () => {
store: { version: 1 as const, jobs: [job] },
} as CronServiceState;
expect(() => recomputeNextRunsForMaintenance(state)).not.toThrow();
recomputeNextRunsForMaintenance(state);
expect(job.state.nextRunAtMs).toBe(future);
expect(job.state.scheduleErrorCount).toBeUndefined();
});