fix(lap): keep best laps per track layout and count the current session for records
A layout switch during a running open practice kept every driver's old-layout best lap, blocking personal-best calls and skewing the practice leaderboard. Best laps now restart on a new layout and each lap records its layout. The track record baseline now includes the current session so the same record isn't called twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,21 @@ test("getTrackRecordMs only compares sessions run on the same track layout once
|
||||
assert.equal(getTrackRecordMs(state.sessions[0], { state }), 15000);
|
||||
});
|
||||
|
||||
test("getTrackRecordMs includes the current session, so a record beaten earlier in it is the new bar", () => {
|
||||
const state = createTrackRecordState({
|
||||
sessions: [
|
||||
{ id: "current", eventId: "event_1", trackLayoutId: "layout_1" },
|
||||
{ id: "older", eventId: "event_1", trackLayoutId: "layout_1" },
|
||||
],
|
||||
results: {
|
||||
older: { competitors: { a: { bestLapMs: 16000 } } },
|
||||
current: { competitors: { b: { bestLapMs: 15000 } } },
|
||||
},
|
||||
});
|
||||
// Driver B already set 15.0 here; a 15.5 must not be called a track record again.
|
||||
assert.equal(getTrackRecordMs(state.sessions[0], { state }), 15000);
|
||||
});
|
||||
|
||||
test("getTrackRecordMs does not conflate a layout-tagged session with an untagged legacy one", () => {
|
||||
const state = createTrackRecordState({
|
||||
sessions: [
|
||||
|
||||
Reference in New Issue
Block a user