feat(day): marshals per heat from the heat before or after, on the schedule, board, printout and heat call (1.89.30)

This commit is contained in:
larssand committed 2026-11-14 16:26:53 +01:00
1 parent 2db77fe6cd
commit 163e82224c
10 files changed
+72 -13

No files matched your search

+12 -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, withRaceSetupStart, eventScheduleFromDayRows } from "../src/day_schedule_logic.js";
import { assignMarshals, 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" },
@@ -211,3 +211,14 @@ test("Race setup shows its race's heats with Race Day's times (lunch and other c
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");
});
test("marshals: the drivers of the heat before (or after), never someone driving the heat", () => {
const entrants = { h1: ["a", "b"], h2: ["c", "d", "a"], h3: ["e"] };
const rows = ["h1", "h2", "h3"].map((id) => ({ session: { id } }));
const of = (session) => entrants[session.id].map((id) => ({ driverId: id, name: id.toUpperCase() }));
const names = (list) => list.map((row) => row.marshals.map((entry) => entry.name).join(""));
assert.deepEqual(names(assignMarshals(rows, "previous", of)), ["", "B", "CDA"], "a drives h2 too, so only b marshals it");
assert.deepEqual(names(assignMarshals(rows, "next", of)), ["CD", "E", ""]);
assert.deepEqual(names(assignMarshals(rows, "off", of)), ["", "", ""]);
assert.equal(normalizeRaceDays([{ date: "2026-11-08", marshalRule: "bogus" }])[0].marshalRule, "off");
});