fix(overlay): Gap shows the gap to the leader, not the same as Gap ahead (1.89.54)

This commit is contained in:
larssand committed 2026-11-16 23:39:00 +01:00
1 parent bfffde86b9
commit 267b22070c
5 files changed
+33 -9

No files matched your search

+17 -1
View File
@@ -62,7 +62,9 @@ test("practice ranked on 3 laps in a row: only result, gap and best lap as times
assert.equal(isPracticeRankedSession({ type: "qualification" }), false, "qualifier on laps and time: full view, like a final");
assert.equal(isPracticeRankedSession({ type: "final" }), false);
const row = { key: "a", driverId: "a", displayName: "Anna", laps: 12, resultDisplay: "3 varv 55.123", gapDisplay: "+0.747s", gapAhead: "+0.2", lapDelta: "-0.1", bestLapMs: 18201, lastLapMs: 18777, predictedRemainingMs: 9000 };
const html = renderOverlayLeaderboard([row], deps, { practiceRank: true });
// The leader shows "-" as its gap; the gap is checked on the driver behind it.
const leader = { key: "l", driverId: "l", displayName: "Lea", laps: 12, resultDisplay: "3 varv 54.376", leaderGap: "Leader", bestLapMs: 18001 };
const html = renderOverlayLeaderboard([leader, { ...row, leaderGap: "+0.747s" }], deps, { practiceRank: true });
assert.match(html, /overlay-race-list-ranked/);
assert.match(html, /pos-pill pos-1">1</);
assert.match(html, /<label>table\.result<\/label>\s*<strong>3 varv 55\.123<\/strong>/);
@@ -77,3 +79,17 @@ test("a driver's country: a small local flag before the name on the overlay; non
assert.match(withFlag, /<img class="country-flag" src="\/src\/flags\/no\.svg"[^>]*\/>Roy/);
assert.doesNotMatch(renderOverlayLeaderboard(rows(1), deps), /country-flag/);
});
test("overlay Gap is the gap to the leader and Gap ahead the gap to the car in front", () => {
const rows = [
{ key: "a", driverId: "a", displayName: "A", laps: 16, resultDisplay: "16/4:47.959", leaderGap: "Leader", gapAhead: "-" },
{ key: "b", driverId: "b", displayName: "B", laps: 15, resultDisplay: "15/4:31.848", leaderGap: "+1L", gapAhead: "+1L" },
{ key: "c", driverId: "c", displayName: "C", laps: 15, resultDisplay: "15/4:36.430", leaderGap: "+1L", gapAhead: "+4.582s" },
];
const html = renderOverlayLeaderboard(rows, deps, {});
const third = html.slice(html.indexOf('data-overlay-competitor="c"'));
assert.match(third, /<label>table\.gap<\/label>\s*<strong>\+1L<\/strong>/);
assert.match(third, /<label>table\.ahead_gap<\/label>\s*<strong>\+4\.582s<\/strong>/);
const first = html.slice(html.indexOf('data-overlay-competitor="a"'), html.indexOf('data-overlay-competitor="b"'));
assert.match(first, /<label>table\.gap<\/label>\s*<strong>-<\/strong>/, "the leader shows -");
});