feat(race): practice seeding setting (EFRA 3 in a row), seeding time in lists and a new-seeding-time call (1.89.49)

This commit is contained in:
larssand committed 2026-11-16 22:39:10 +01:00
1 parent f2adc67695
commit 576847279d
15 files changed
+146 -17

No files matched your search

+26
View File
@@ -56,3 +56,29 @@ test("qualifying seed notice: preliminary until practice is run, then a reminder
assert.equal(getQualifyingSeedNotice(ev, [ran, { ...q, status: "finished", startedAt: 5 }]), null, "qualifying started");
assert.equal(getQualifyingSeedNotice(ev, [q]), null, "no practice");
});
test("practice seeding: format values go onto the practice heats, also ones already run", async () => {
const { applyFormatToPendingSessions } = await import("../src/event_race_logic.js");
const ev = event(4, 10, { practiceSeedLapCount: 3, practiceSeedMethod: "consecutive" });
const [heat] = buildPracticeHeats(ev, 1, { t, buildRaceSession: (eventId, name, type, durationMin, o = {}) => ({ id: "x", eventId, name, type, status: "ready", driverIds: o.driverIds, seedBestLapCount: o.seedBestLapCount, seedMethod: o.seedMethod }) });
assert.equal(heat.seedBestLapCount, 3);
assert.equal(heat.seedMethod, "consecutive");
const ran = { type: "practice", status: "finished", startedAt: 1, seedBestLapCount: 0, seedMethod: "best_sum" };
applyFormatToPendingSessions([ran], { practiceSeedLapCount: 0, practiceSeedMethod: "best_sum" }, { practiceSeedLapCount: 3, practiceSeedMethod: "consecutive" });
assert.equal(ran.seedBestLapCount, 3);
assert.equal(ran.seedMethod, "consecutive");
});
test("practice seeding: a driver without N laps ranks after everyone with a seeding time", async () => {
const { buildPracticeStandings } = await import("../src/timing_logic.js");
const session = { id: "p", type: "practice", seedBestLapCount: 3 };
const rows = [{ driverId: "a", driverName: "A", bestLapMs: 17000, laps: 2 }, { driverId: "b", driverName: "B", bestLapMs: 18000, laps: 5 }];
const standings = buildPracticeStandings({ id: "e1" }, {
getSessionsForEvent: () => [session],
buildLeaderboard: () => rows,
getCompetitorSeedMetric: (_s, row) => (row.driverId === "b" ? { comparableMs: 54500, totalMs: 54500 } : null),
formatSeedMetric: () => "3/54.500",
formatRaceClock: () => "",
});
assert.deepEqual(standings.map((row) => row.driverId), ["b", "a"]);
});