fix(admin): record the pulse rebuild and let a stopped one run again

The rebuild after apply now writes its state beside the dry run
(queued, running, done with counts, failed); a run left queued or
running without a job reads as failed. The card shows it and offers a
new rebuild after a failure, which the route accepts once the method is
applied, without a new dry run.
This commit is contained in:
Marc-André Bombeck committed 2026-10-16 05:55:31 +02:00
1 parent cc9d523bc8
commit f360d221e1
16 files changed
+483 -49

No files matched your search

@@ -37,7 +37,12 @@ const RESULT = {
const status = (
lastDryRun: PulseDayMeanStatus["lastDryRun"],
method: PulseDayMeanStatus["method"] = "hour_mean_v1",
): PulseDayMeanStatus => ({ method, appliedAt: null, lastDryRun });
): PulseDayMeanStatus => ({
method,
appliedAt: null,
lastDryRun,
lastRebuild: null,
});
const done = (finishedAt: string) => ({
status: "done" as const,
@@ -113,4 +118,33 @@ describe("PulseDayMeanCard", () => {
expect(de).toContain("Dünne Stunden gewichtet");
expect(de).toContain("Probelauf");
});
it("shows a stopped recalculation and offers it again without a dry run", () => {
const failed: PulseDayMeanStatus = {
...status(done("2026-10-01T10:00:00Z"), "weighted_hour_mean_v2"),
appliedAt: "2026-10-01T11:00:00Z",
lastRebuild: {
status: "failed",
startedAt: "2026-10-01T11:00:00Z",
finishedAt: "2026-10-01T11:05:00Z",
accounts: null,
rows: null,
},
};
const html = render(failed);
expect(html).toContain('data-state="failed"');
expect(html).toContain('data-testid="admin-pulse-day-mean-rebuild"');
const finished = render({
...failed,
lastRebuild: {
...failed.lastRebuild!,
status: "done",
accounts: 3,
rows: 900,
},
});
expect(finished).not.toContain("admin-pulse-day-mean-rebuild");
expect(finished).toContain('data-slot="pulse-day-mean-rebuild"');
});
});