feat(race-day): call the next heat - asked by hand, automatic with the autopilot (1.51.0)

This commit is contained in:
larssand committed 2026-11-01 22:25:43 +01:00
1 parent fdc6c179dc
commit b2e08db3d8
15 files changed
+178 -31

No files matched your search

+14
View File
@@ -68,3 +68,17 @@ test("race days are stored one per date, and the board shows today or the next d
assert.equal(pickBoardDate({ events, sessions, today: "2026-11-01" }), "2026-11-08");
assert.equal(pickBoardDate({ events, sessions, today: "2026-12-01" }), "2026-12-01");
});
test("a heat is due for its call within callMin, once, and not while put off or the day is paused", async () => {
const { getDueCall } = await import("../src/day_schedule_logic.js");
const start = Date.UTC(2026, 10, 8, 10, 0);
const rows = buildDaySchedule([s("one", "e2", "qualification", "Q1 H1"), s("two", "e2", "qualification", "Q1 H2")], { startAt: start, gapMin: 3 }, start - 3600000);
const day = { callMin: 10 };
assert.equal(getDueCall(rows, { day, now: start - 11 * 60000 }), null);
assert.equal(getDueCall(rows, { day, now: start - 10 * 60000 }).session.id, "one");
const called = rows.map((row, i) => (i === 0 ? { ...row, session: { ...row.session, calledAt: start - 600000 } } : row));
assert.equal(getDueCall(called, { day, now: start - 5 * 60000 }), null, "the next heat is not due yet");
assert.equal(getDueCall(called, { day, now: start }).session.id, "two");
assert.equal(getDueCall(rows, { day, now: start - 5 * 60000, snoozedUntil: () => start - 3 * 60000 }), null, "put off");
assert.equal(getDueCall(rows, { day: { ...day, pausedAt: 1 }, now: start }), null);
});