feat(overlay): last lap column in the OBS tower and the Open Practice leaderboard (1.89.4)

This commit is contained in:
larssand committed 2026-11-10 19:41:19 +01:00
1 parent f5ff1b9acd
commit d5f81f4290
10 files changed
+73 -16

No files matched your search

+29
View File
@@ -22,3 +22,32 @@ test("sponsor heats: the overlay shows the driver's car for this heat", () => {
const html = renderOverlayLeaderboard([{ key: "a", driverId: "a", displayName: "Anna", heatCarName: "Rental 2", laps: 3, resultDisplay: "-", bestLapMs: 17500 }], deps);
assert.match(html, /overlay-heat-car[^>]*>🚗 Rental 2/);
});
test("open practice: the last lap takes the result's place (the result only repeats the best lap)", () => {
const row = { key: "a", driverId: "a", displayName: "Anna", laps: 12, resultDisplay: "0:17.100", bestLapMs: 17100, lastLapMs: 17842 };
const practice = renderOverlayLeaderboard([row], deps, { lastLap: true });
assert.match(practice, /<label>table\.last_lap<\/label>\s*<strong>17842<\/strong>/);
assert.doesNotMatch(practice, /<label>table\.result<\/label>/);
const race = renderOverlayLeaderboard([row], deps);
assert.match(race, /<label>table\.result<\/label>\s*<strong>0:17\.100<\/strong>/);
assert.match(renderOverlayLeaderboard([{ ...row, lastLapMs: 0 }], deps, { lastLap: true }), /<label>table\.last_lap<\/label>\s*<strong>-<\/strong>/);
});
test("OBS tower: a Last column with each passing's lap time, next to laps", async () => {
const { renderObsOverlay } = await import("../src/overlays.js");
const config = { layout: "broadcast", rows: 10, showLaps: true, showLast: true, showResult: true, showBest: true, showGap: true };
const obsDeps = { ...deps, formatLap: (ms) => (ms / 1000).toFixed(3), getVisiblePassings: () => [], getEventName: () => "", getSessionTypeLabel: () => "", getStartModeLabel: () => "", getStatusLabel: () => "", getObsOverlayConfig: () => config, normalizeStartMode: (v) => v, renderPositionGrid: () => "", getSessionGridEntries: () => [], getSessionGridOrder: () => [] };
const html = renderObsOverlay({ eventId: "e", name: "Open practice", type: "open_practice", status: "running" }, [{ key: "p", driverId: "p", displayName: "Pia", laps: 23, resultDisplay: "0:15.833", bestLapMs: 15833, lastLapMs: 16120 }], {}, {}, {}, obsDeps);
assert.match(html, /obs-tv-laps">23<\/span><span class="obs-tv-cell obs-tv-last">16\.120<\/span>/);
assert.doesNotMatch(html, /obs-tv-result">0:15/, "practice still drops the result that repeats the best lap");
config.showLast = false;
assert.doesNotMatch(renderObsOverlay({ eventId: "e", name: "Q1", type: "qualification", status: "running" }, [{ key: "p", driverId: "p", displayName: "Pia", laps: 23, resultDisplay: "23/5:02", bestLapMs: 15833, lastLapMs: 16120 }], {}, {}, {}, obsDeps), /obs-tv-last/);
});
test("an Open Practice ranked on laps in a row or minutes keeps its result", async () => {
const { isOpenPracticeSession } = await import("../src/overlays.js");
assert.equal(isOpenPracticeSession({ type: "open_practice" }), true);
assert.equal(isOpenPracticeSession({ type: "open_practice", practiceRanking: "consecutive" }), false);
assert.equal(isOpenPracticeSession({ type: "free_practice", practiceRanking: "window" }), false);
assert.equal(isOpenPracticeSession({ type: "qualification" }), false);
});