feat(day): one start time - Race setup's start time and gap are Race Day's, with Race Day's times shown (1.89.17)

This commit is contained in:
larssand committed 2026-11-13 09:40:48 +01:00
1 parent cb29c5471b
commit f8080ffaeb
11 files changed
+122 -17

No files matched your search

+24 -1
View File
@@ -1,6 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
import { orderDaySessions, buildDaySchedule, getAutopilotAction, normalizeRaceDays, moveInDayOrder, pickBoardDate, fixedBreakWindow } from "../src/day_schedule_logic.js";
import { orderDaySessions, buildDaySchedule, getAutopilotAction, normalizeRaceDays, moveInDayOrder, pickBoardDate, fixedBreakWindow, withRaceSetupStart, eventScheduleFromDayRows } from "../src/day_schedule_logic.js";
const events = [
{ id: "e4", name: "Cup #1 4WD", date: "2026-11-08", mode: "race" },
@@ -170,3 +170,26 @@ test("a heat already run between pending ones doesn't pull the rest of the day b
const rows = buildDaySchedule(sessions, { startAt: T("23:40"), gapMin: 3 }, T("23:39")).filter((row) => row.state === "upcoming");
assert.deepEqual(rows.map((row) => row.start), [T("23:40"), T("23:48"), T("23:56")], "one after the other from the first start, not all at 23:39");
});
test("one start time: Race Day's first start; a Race setup start time from before fills in a day without one", () => {
const at = new Date("2026-11-14T09:30:00").getTime();
const events = [{ id: "e", date: "2026-11-14", raceConfig: { scheduleStartAt: at } }];
assert.equal(withRaceSetupStart({ date: "2026-11-14", startAt: null }, events).startAt, at);
const own = new Date("2026-11-14T10:00:00").getTime();
assert.equal(withRaceSetupStart({ date: "2026-11-14", startAt: own }, events).startAt, own, "Race Day's own time wins");
assert.equal(withRaceSetupStart({ date: "2026-11-15", startAt: null }, events).startAt, null, "another day is not touched");
});
test("Race setup shows its race's heats with Race Day's times (lunch and other classes included)", () => {
const T = (h) => new Date(`2026-11-14T${h}:00`).getTime();
const sessions = [
{ id: "a1", eventId: "a", type: "qualification", name: "Q1 H1", status: "ready", durationMin: 5 },
{ id: "b1", eventId: "b", type: "qualification", name: "Q1 H1", status: "ready", durationMin: 5 },
{ id: "a2", eventId: "a", type: "qualification", name: "Q2 H1", status: "ready", durationMin: 5 },
];
const rows = buildDaySchedule(sessions, { date: "2026-11-14", startAt: T("11:50"), gapMin: 2, breakFrom: "12:00", breakTo: "13:00" }, T("08:00"));
const own = eventScheduleFromDayRows(rows, "a");
assert.deepEqual(own.map((row) => row.sessionId), ["a1", "a2"]);
assert.equal(own[0].plannedStart, T("11:50"));
assert.equal(own[1].plannedStart, T("13:07"), "the other class would run into lunch, goes 13:00-13:05, then a2 after the gap");
});