fix(dashboard): schedule drift counts only today's timed heats; clearer practice texts in the race wizard (1.89.45)

This commit is contained in:
larssand committed 2026-11-16 21:37:11 +01:00
1 parent d07d4477b7
commit ce86f771c3
8 files changed
+51 -9

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import test from "node:test";
import assert from "node:assert/strict";
import { getScheduleDriftSummary } from "../src/core_views.js";
const now = new Date(2026, 10, 16, 21, 0, 0).getTime();
const min = 60000;
test("schedule drift: nothing started today shows no drift", () => {
const lastWeek = now - 3 * 24 * 60 * min;
const state = { sessions: [{ type: "qualification", durationMin: 5, startedAt: lastWeek, endedAt: lastWeek + 6 * min, status: "finished" }] };
assert.equal(getScheduleDriftSummary(state, now), null);
});
test("schedule drift: a running open practice never counts", () => {
const state = { sessions: [{ type: "open_practice", durationMin: 0, startedAt: now - 130 * min, status: "running" }] };
assert.equal(getScheduleDriftSummary(state, now), null);
});
test("schedule drift: today's timed heats are compared with their planned length", () => {
const state = { sessions: [
{ type: "qualification", durationMin: 5, startedAt: now - 60 * min, endedAt: now - 53 * min, status: "finished" },
{ type: "free_practice", durationMin: 0, startedAt: now - 120 * min, endedAt: now - 70 * min, status: "finished" },
] };
assert.deepEqual(getScheduleDriftSummary(state, now), { plannedMs: 5 * min, actualMs: 7 * min, driftMs: 2 * min });
});