feat(race-day): offer Create finals once every qualifying heat has run (1.84.0)

This commit is contained in:
larssand committed 2026-11-08 20:57:28 +01:00
1 parent ebdc6104e6
commit 0a4c017e44
9 files changed
+112 -7

No files matched your search

+21
View File
@@ -124,3 +124,24 @@ test("Race Day preflight warns when the decoder's clock is off, but never blocks
state.decoder.clockSkewMs = 25; // network delay only
assert.equal(buildRaceDayPreflight(state, state.sessions[0], { backendAvailable: true }).checks.some((item) => item.id === "decoder_clock"), false);
});
test("Race Day offers Create finals once every heat the finals come from has run, and only once", async () => {
const { shouldOfferFinals } = await import("../src/race_day_logic.js");
const state = {
events: [{ id: "e", raceConfig: {} }, { id: "p", raceConfig: { finalsSource: "practice" } }, { id: "s", mode: "track", sponsor: {}, raceConfig: {} }],
sessions: [
{ eventId: "e", type: "practice", status: "finished" },
{ eventId: "e", type: "qualification", status: "finished" },
{ eventId: "e", type: "qualification", status: "ready" },
{ eventId: "p", type: "practice", status: "stopped" },
{ eventId: "s", type: "qualification", status: "finished" },
],
};
assert.equal(shouldOfferFinals(state, "e"), false, "a qualifying heat is still to run");
state.sessions[2].status = "finished";
assert.equal(shouldOfferFinals(state, "e"), true);
assert.equal(shouldOfferFinals(state, "p"), true, "finals seeded from practice");
assert.equal(shouldOfferFinals(state, "s"), false, "sponsor events have their own flow");
state.sessions.push({ eventId: "e", type: "final", status: "ready" });
assert.equal(shouldOfferFinals(state, "e"), false, "finals already made");
});