feat(race-day): live race for the race controller with order, laps, gaps and estimated finish (1.47.0)

This commit is contained in:
larssand committed 2026-11-01 16:38:08 +01:00
1 parent c4163441fc
commit 54487a18a6
12 files changed
+169 -7

No files matched your search

+22
View File
@@ -66,6 +66,28 @@ export async function runRaceDayQuickSmoke({ evaluate, navigate, savedState, wai
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayStart")`)), "Start is offered again");
console.log("PASS a finished heat can be picked and reset: clock to zero, laps cleared, Start again");
// The race controller follows the heat on Race Day: order, laps, last/best lap, estimate.
const liveAt = Date.now() - 60000;
const competitor = (key, name, laps, lastLapMs, bestLapMs, elapsedMs) => ({ key, driverName: name, displayName: name, laps, lastLapMs, bestLapMs, startTimestamp: liveAt, lastTimestamp: liveAt + elapsedMs });
await patchState({
sessions: [...(await savedState()).sessions.filter((session) => session.status !== "running"), { id: "rq_live", eventId: "rq_event", name: "RQ Heat 3", type: "heat", status: "running", durationMin: 5, startMode: "mass", startedAt: liveAt }],
resultsBySession: { ...(await savedState()).resultsBySession, rq_live: { passings: [], adjustments: [], competitors: {
slow: competitor("slow", "Slow Sam", 2, 26000, 25000, 52000),
fast: competitor("fast", "Fast Fia", 3, 19000, 18500, 57000),
} } },
activeSessionId: "rq_live",
});
await navigate("race_day", "raceDayLive");
const liveRows = await evaluate(`JSON.stringify([...document.querySelectorAll("#raceDayLive tbody tr")].map((row) => [...row.cells].map((cell) => cell.textContent.trim())))`);
const [first, second] = JSON.parse(liveRows);
assert.deepEqual([first[0], first[1], first[2], second[1], second[2]], ["1", "Fast Fia", "3", "Slow Sam", "2"], "the running order with laps");
assert.match(first[3], /19\.0/, "last lap");
assert.match(first[4], /18\.5/, "best lap");
assert.match(first[7], /^16 · /, "estimated laps when the time is up");
assert.equal(await evaluate(`document.querySelector("#raceDayLive .is-fastest")?.closest("tr").cells[1].textContent.includes("Fast Fia")`), true, "the heat's fastest lap is marked");
await patchState({ sessions: (await savedState()).sessions.map((session) => (session.id === "rq_live" ? { ...session, status: "finished", endedAt: Date.now() } : session)) });
console.log("PASS Race Day shows the live race: order, laps, last and best lap, gaps and estimated finish");
await navigate("timing", "activeSessionSelect");
assert.equal(await evaluate(`Boolean(document.getElementById("startSession") || document.getElementById("resetSession") || document.getElementById("stopSession"))`), false, "no run controls on Timing");
await evaluate(`document.getElementById("timingOpenRaceDay").click()`);