feat(day): several fixed breaks a day (lunch, prize-giving ...) in Race Day's schedule (1.89.26)

This commit is contained in:
larssand committed 2026-11-14 15:31:10 +01:00
1 parent 239cac8033
commit 5241cced77
11 files changed
+147 -47

No files matched your search

+18
View File
@@ -145,6 +145,24 @@ test("a break at fixed clock times (lunch 12-13): no heat starts or runs inside
assert.equal(fixedBreakWindow(day).label, "Lunch");
});
test("several fixed breaks a day: each moves the heat that would hit it, the old single break carries over", () => {
const at = (hhmm) => new Date(`2026-11-08T${hhmm}:00`).getTime();
const list = ["a", "b", "c", "d"].map((id, i) => s(id, "e2", "qualification", `Q1 H${i + 1}`));
const day = { date: "2026-11-08", startAt: at("11:50"), gapMin: 2, fixedBreaks: [{ from: "15:00", to: "15:20", label: "Prisutdelning" }, { from: "12:00", to: "13:00", label: "Lunch" }, { from: "13:05", to: "13:15", label: "Banunderhåll" }] };
const plan = buildDaySchedule(list, day, at("08:00"));
// a 11:50-11:55; b 11:57 runs into lunch -> 13:00, but 13:00-13:05 ends as the track break starts: ok;
// c 13:07 runs into the track break -> 13:15; d 13:22.
assert.deepEqual(plan.map((row) => new Date(row.start).toTimeString().slice(0, 5)), ["11:50", "13:00", "13:15", "13:22"]);
assert.deepEqual(plan.map((row) => row.afterBreak?.label || ""), ["", "Lunch", "Banunderhåll", ""]);
// Sorted, and an overlapping or backwards break is dropped.
const normalized = normalizeRaceDays([{ date: "2026-11-08", fixedBreaks: [{ from: "13:00", to: "14:00" }, { from: "12:00", to: "13:30" }, { from: "16:00", to: "15:00" }] }])[0];
assert.deepEqual(normalized.fixedBreaks.map((item) => item.from), ["12:00"]);
// A day saved with the single break keeps it as the first entry.
const old = normalizeRaceDays([{ date: "2026-11-08", breakFrom: "12:00", breakTo: "12:45", breakLabel: "Lunch" }])[0];
assert.deepEqual(old.fixedBreaks, [{ from: "12:00", to: "12:45", label: "Lunch" }]);
assert.equal(normalizeRaceDays([{ date: "2026-11-08", breakFrom: "12:00", breakTo: "12:45", fixedBreaks: [] }])[0].breakFrom, null, "an emptied list wins over the old fields");
});
test("the drivers' board shows the lunch while it is on, and before the heat after it", async () => {
const { renderDriverBoard } = await import("../src/day_schedule_view.js");
const at = (hhmm) => new Date(`2026-11-08T${hhmm}:00`).getTime();