fix(timing): keep timing the running session when another one is selected
Passings and the session clock followed only the selected session, so selecting another practice or the next heat while one was running dropped every lap. They now go to the running session, and Timing and Race Day show where laps are being recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cdde070c1c
commit
3a6789f42f
13 files changed
+137
-13
No files matched your search
@@ -16,3 +16,15 @@ test("places gained or lost since the start - only for heats and finals started
|
||||
assert.equal(getPositionChange({ ...final, startMode: "flying" }, order, "e", 2), null, "no common start order");
|
||||
assert.equal(getPositionChange(null, order, "e", 2), null);
|
||||
});
|
||||
|
||||
test("laps go to the session actually running when another one is selected", async () => {
|
||||
const { getLiveSession } = await import("../src/timing_logic.js");
|
||||
const session = (id, status, startedAt = 0) => ({ id, status, startedAt });
|
||||
const state = (activeSessionId, sessions) => ({ activeSessionId, sessions });
|
||||
assert.equal(getLiveSession({ state: state("b", [session("a", "running", 1), session("b", "running", 2)]) }).id, "b", "the selected session when it runs");
|
||||
assert.equal(getLiveSession({ state: state("next", [session("heat", "running", 5), session("next", "ready")]) }).id, "heat", "next heat picked while the current one runs");
|
||||
assert.equal(getLiveSession({ state: state("op2", [session("op1", "running", 5), session("op2", "ready"), session("old", "running", 1)]) }).id, "op1", "the most recently started running session");
|
||||
assert.equal(getLiveSession({ state: state("b", [session("a", "paused", 3), session("b", "finished")]) }).id, "a", "a paused session still counts as live");
|
||||
assert.equal(getLiveSession({ state: state("b", [session("a", "finished"), session("b", "ready")]) }).id, "b", "nothing running: the selected one");
|
||||
assert.equal(getLiveSession({ state: state("", []) }), null);
|
||||
});
|
||||
Reference in new issue
Block a user