fix(workflow): propagate cancellation in latest-job snapshots

This commit is contained in:
gitea committed 2026-10-20 23:01:00 +08:00
commit 70d619e464
5 files changed
+38 -21

No files matched your search

@@ -111,7 +111,8 @@ export async function watchWorkflowPipeline(
pipelineId,
totalJobsWatched: 1,
jobs: [singleRes],
timedOut: false,
timedOut: Boolean(singleRes.timedOut),
cancelled: singleRes.cancelled,
hasFailures: singleRes.hasError || singleRes.status === "FAILED",
};
}
@@ -27,3 +27,17 @@ test("cancellation is distinct from timeout and completion", async () => {
expect(result.events.map(e => e.type)).toEqual(["cancelled"]);
expect(c.get).not.toHaveBeenCalled();
});
test("latest-job snapshots propagate cancellation from the selected job", async () => {
const controller = new AbortController();
const c = { get: async (path: string) => {
if (path.endsWith("/running")) return Response.json({ data: [{ id: "job", pipelineId: "wf" }] });
if (path.includes("/pipelines/")) return Response.json({ data: { id: "wf", tasks: [] } });
if (path.includes("/execution")) return Response.json({ data: [] });
controller.abort();
return Response.json({ data: { id: "job", pipelineId: "wf", status: "RUNNING" } });
} } as any;
const report = await watchWorkflowPipeline(c, "wf", { once: true, signal: controller.signal });
expect(report.cancelled).toBe(true); expect(report.timedOut).toBe(false);
expect(report.jobs[0].events.some(e => e.type === "job_completed")).toBe(false);
});