fix(race-day): reset a heat to ready with its clock at zero, keep recent races listed (1.45.2)

This commit is contained in:
larssand committed 2026-11-01 10:49:17 +01:00
1 parent 7376595001
commit ab1c26a89b
7 files changed
+62 -14

No files matched your search

+18
View File
@@ -47,6 +47,24 @@ export async function runRaceDayQuickSmoke({ evaluate, navigate, savedState, wai
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayResetSession")`)), "Reset data is on Race Day for a heat that is not running");
console.log("PASS Race Day's session picker switches the selected session");
// A finished heat can be picked again and reset to run again: clock back to zero, no laps.
const ranAt = Date.now() - 600000;
await patchState({
sessions: [...(await savedState()).sessions, { id: "rq_done", eventId: "rq_event", name: "RQ Heat 2", type: "qualification", status: "finished", durationMin: 5, startedAt: ranAt, endedAt: ranAt + 300000, finishedByTimer: true }],
resultsBySession: { ...(await savedState()).resultsBySession, rq_done: { passings: [{ id: "p1", timestamp: ranAt + 20000, lapMs: 20000 }], competitors: {}, adjustments: [] } },
});
await navigate("race_day", "raceDaySessionSelect");
assert.ok(await evaluate(`[...document.getElementById("raceDaySessionSelect").options].some((option) => option.value === "rq_done")`), "the finished heat is in the list");
await evaluate(`(() => { const select = document.getElementById("raceDaySessionSelect"); select.value = "rq_done"; select.dispatchEvent(new Event("change")); })()`);
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayResetSession")`)), "Reset data for the finished heat");
await evaluate(`document.getElementById("raceDayResetSession").click()`);
await waitFor(async () => (await savedState()).sessions.find((session) => session.id === "rq_done")?.status === "ready", "the heat is ready to run again");
const reset = (await savedState()).sessions.find((session) => session.id === "rq_done");
assert.deepEqual([reset.startedAt || null, reset.endedAt || null, reset.finishedByTimer], [null, null, false], "the clock is back at zero");
assert.equal((await savedState()).resultsBySession.rq_done?.passings?.length || 0, 0, "its laps are cleared");
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");
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()`);
+9 -2
View File
@@ -25,9 +25,16 @@ test("Race Day picker: today's races, live and selected sessions, grouped per ra
["old", ["old_practice"]],
["next", ["n_practice"]],
["today", ["t_practice", "t_q1"]],
["undated", ["u_ready"]],
["undated", ["u_ready", "u_done"]],
]);
assert.equal(result.hidden, 2);
assert.equal(result.hidden, 1);
});
test("Race Day picker: a race run in the last 12 hours stays listed after midnight", () => {
const now = Date.parse("2026-11-09T00:30:00");
const ran = sessions.map((session) => session.id === "t_practice" ? { ...session, startedAt: now - 3600 * 1000 } : session);
const result = buildRaceDaySessionGroups({ sessions: ran, events, today: "2026-11-09", now });
assert.deepEqual(ids(result).find(([id]) => id === "today"), ["today", ["t_practice", "t_q1"]], "yesterday's race, finished heats included");
});
test("Race Day picker: show all lists every session", () => {