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:
@@ -72,6 +72,20 @@ function createHarness() {
|
||||
};
|
||||
}
|
||||
|
||||
test("recalculating after a judge correction keeps the best lap on the current track layout", () => {
|
||||
const harness = createHarness();
|
||||
harness.session.trackLayoutId = "layout_b";
|
||||
harness.result.passings[0].trackLayoutId = "layout_a"; // the 16.0 s lap was on the old layout
|
||||
harness.result.passings[1].trackLayoutId = "layout_b";
|
||||
harness.result.passings[2].trackLayoutId = "layout_b";
|
||||
harness.deps.recalculateCompetitorFromPassings(harness.session, "driver_1");
|
||||
assert.equal(harness.row.bestLapMs, 16500);
|
||||
assert.equal(harness.row.laps, 3, "laps from the old layout still count as laps");
|
||||
delete harness.result.passings[0].trackLayoutId; // untagged (from before layouts were tagged) still counts
|
||||
harness.deps.recalculateCompetitorFromPassings(harness.session, "driver_1");
|
||||
assert.equal(harness.row.bestLapMs, 16000);
|
||||
});
|
||||
|
||||
test("manual corrections accumulate, reset, and undo to the prior state", () => {
|
||||
const harness = createHarness();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user