fix(cron): show running status for active paused jobs (#129339)

This commit is contained in:
Peter Steinberger
2026-08-26 10:41:06 -07:00
committed by GitHub
parent 3be7baa1a3
commit f498727bbd
2 changed files with 40 additions and 8 deletions
+37 -5
View File
@@ -474,27 +474,59 @@ describe("printCronList", () => {
);
it.each([
{ label: "disabled", enabled: false, runStatus: "ok" as const, expectedStatus: "disabled" },
{ label: "running", enabled: true, runStatus: "ok" as const, expectedStatus: "running" },
{ label: "failed", enabled: true, runStatus: "error" as const, expectedStatus: "error" },
{
label: "disabled",
enabled: false,
running: false,
runStatus: "ok" as const,
expectedStatus: "disabled",
},
{
label: "running",
enabled: true,
running: true,
runStatus: "ok" as const,
expectedStatus: "running",
},
{
label: "paused but force-running",
enabled: false,
running: true,
runStatus: "ok" as const,
expectedStatus: "running",
},
{
label: "failed",
enabled: true,
running: false,
runStatus: "error" as const,
expectedStatus: "error",
},
])(
"does not let prior non-delivery override a $label automation",
({ enabled, runStatus, expectedStatus }) => {
({ enabled, running, runStatus, expectedStatus }) => {
const job = createBaseJob({
enabled,
state: {
lastRunStatus: runStatus,
lastDeliveryStatus: "not-delivered",
...(expectedStatus === "running" ? { runningAtMs: Date.now() } : {}),
...(running ? { runningAtMs: Date.now() } : {}),
},
});
const list = createRuntimeLogCapture();
printCronList([job], list.runtime);
expectLogsToInclude(list.logs, expectedStatus);
const show = createRuntimeLogCapture();
printCronShow(job, show.runtime);
expectLogsToInclude(show.logs, `status: ${expectedStatus}`);
expect(show.logs.join("\n")).not.toContain("ok (not delivered)");
expect(enrichCronJsonWithStatus(job)).toMatchObject({ status: expectedStatus });
expect(enrichCronJsonWithStatus({ jobs: [job] })).toMatchObject({
jobs: [{ status: expectedStatus }],
});
},
);
+3 -3
View File
@@ -170,13 +170,13 @@ export function enrichCronJsonWithStatus(value: unknown): unknown {
}
function computeStatus(job: { enabled?: unknown; state?: unknown }): string {
if (!job.enabled) {
return "disabled";
}
const state = asOptionalRecord(job.state) ?? {};
if (state.runningAtMs) {
return "running";
}
if (!job.enabled) {
return "disabled";
}
return typeof state.lastRunStatus === "string"
? state.lastRunStatus
: typeof state.lastStatus === "string"