fix(results): same laps ranked by lowest total time, not closest to the set time (1.57.1)
This commit is contained in:
1 parent
221a06c899
commit
e1ca72db51
5 files changed
+45
-15
No files matched your search
@@ -813,9 +813,9 @@ test("points tables, tie comparison, and leaderboard gaps remain deterministic",
|
||||
assert.equal(formatLeaderboardGap({ key: "second", laps: 16, totalElapsedMs: 290000 }, leader, {}, { t }), "+1L");
|
||||
assert.equal(
|
||||
formatLeaderboardGap(
|
||||
{ key: "second", laps: 17, totalElapsedMs: 306000, distanceToTargetMs: 6000 },
|
||||
{ key: "second", laps: 17, totalElapsedMs: 306000 },
|
||||
leader,
|
||||
{ useTargetTieBreak: true },
|
||||
{},
|
||||
{ t }
|
||||
),
|
||||
"+5.000s"
|
||||
@@ -1082,3 +1082,33 @@ test("ensureSessionResult backfills a missing passings array on an already-exist
|
||||
const brandNew = ensureSessionResult("session_2", { state });
|
||||
assert.deepEqual(brandNew, { passings: [], splits: [], pitEvents: [], pitStops: [], competitors: {}, adjustments: [] });
|
||||
});
|
||||
|
||||
// Race report: a finished heat, two cars on 10 laps - 4:51 must beat 4:52, even though 4:52
|
||||
// is closer to the 5:00 set time.
|
||||
test("buildLeaderboard: same laps in a finished heat - the lower total time wins", () => {
|
||||
const start = 1_000_000;
|
||||
const competitors = {
|
||||
slow: { key: "slow", driverName: "Slow", startTimestamp: start, laps: 10, lastTimestamp: start + 292000, manualLapAdjustment: 0, manualTimeAdjustmentMs: 0 },
|
||||
fast: { key: "fast", driverName: "Fast", startTimestamp: start, laps: 10, lastTimestamp: start + 291000, manualLapAdjustment: 0, manualTimeAdjustmentMs: 0 },
|
||||
};
|
||||
for (const type of ["qualification", "final"]) {
|
||||
const rows = buildLeaderboard({ id: "h", type, startMode: "position", status: "finished", startedAt: start, durationMin: 5, totalPausedMs: 0 }, {
|
||||
ensureSessionResult: () => ({ competitors }),
|
||||
getSessionTargetMs: (s) => getSessionTargetMs(s, { isUntimedSession }),
|
||||
getCompetitorPassings: () => [],
|
||||
isCountedPassing: () => true,
|
||||
getCompetitorElapsedMs,
|
||||
getCompetitorSeedMetric: () => null,
|
||||
getSessionLapWindow: () => ({ minLapMs: 0, maxLapMs: Infinity }),
|
||||
getPassingValidationLabel: () => "",
|
||||
formatSeedMetric: () => "",
|
||||
formatRaceClock: (ms) => `${ms}`,
|
||||
formatLeaderboardGap: (row, ref, options) => formatLeaderboardGap(row, ref, options, { t: (key) => key }),
|
||||
formatLapDelta: () => "",
|
||||
formatLap: (ms) => `${ms}`,
|
||||
t: (key) => key,
|
||||
});
|
||||
assert.deepEqual(rows.map((row) => row.key), ["fast", "slow"], type);
|
||||
assert.equal(rows[1].gap, "+1.000s");
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user