feat(race-day): call the practice reset "Reset – new practice day"

"New practice day" didn't say that it resets. Also a test that several
resets of the same Open Practice (even the same day) keep every lap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-19 08:38:43 +02:00
1 parent 2c6c37f6ca
commit 633e0efa1f
5 files changed
+37 -9

No files matched your search

+26
View File
@@ -180,6 +180,32 @@ test("resetting a running Open Practice keeps its earlier laps in the training s
assert.deepEqual(training.ledger.map((entry) => entry.lapMs), [20000, 19500, 19000]);
});
test("resetting the same Open Practice several times (even the same day) keeps every lap", () => {
const lap = (lapMs, timestamp) => ({ driverId: "driver_1", competitorKey: "driver_1", lapMs, timestamp, validLap: true });
const state = {
sessions: [{ id: "op", name: "Open Practice", type: "open_practice", eventId: "event_1" }],
events: [{ id: "event_1", name: "Club" }],
resultsBySession: { op: { passings: [lap(20000, 1000), lap(19000, 2000)] } },
};
let training = syncTrainingLedger({}, state, { uid: createUid() });
// Each reset syncs first (as resetSessionData does), then clears; the next laps restart at
// index 0 in the results, so they must not overwrite the earlier ones.
const reset = (at) => {
training = syncTrainingLedger(training, state, { uid: createUid() });
state.sessions[0].resultsResetAt = at;
delete state.resultsBySession.op;
training = syncTrainingLedger(training, state, { uid: createUid() });
};
reset(3000);
state.resultsBySession.op = { passings: [lap(18500, 4000), lap(18000, 5000)] };
reset(6000);
state.resultsBySession.op = { passings: [lap(17500, 7000)] };
reset(8000);
state.resultsBySession.op = { passings: [lap(17000, 9000)] };
training = syncTrainingLedger(training, state, { uid: createUid() });
assert.deepEqual(training.ledger.map((entry) => entry.lapMs), [20000, 19000, 18500, 18000, 17500, 17000]);
});
test("driver statistics remain isolated and aggregate days and sessions", () => {
const firstDay = new Date(2026, 0, 10, 12, 0, 0).getTime();
const secondDay = new Date(2026, 0, 11, 12, 0, 0).getTime();