fix(race): never remake qualifying or finals that have already run; clearing them asks first (1.89.36)
This commit is contained in:
1 parent
01abe5b7ae
commit
93c590e5b8
8 files changed
+66
-17
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
buildRaceFormatConfigFromForm,
|
||||
buildRaceSessionsFromWizard,
|
||||
generateFinalsForRace,
|
||||
getRunGeneratedSessions,
|
||||
generateQualifyingForRace,
|
||||
normalizeHeatOrder,
|
||||
getEventDrivers,
|
||||
@@ -1126,3 +1127,23 @@ test("sponsor heats: each row carries the car the driver has in this heat, other
|
||||
assert.equal(sponsor.find((row) => row.key === "b").heatCarName, "", "a car not handed out in this heat is not shown");
|
||||
assert.ok(buildLeaderboard({ id: "club", type: "heat", startMode: "mass" }, deps).every((row) => row.heatCarName === ""));
|
||||
});
|
||||
|
||||
test("finals that already ran are never made again by mistake - Generate refuses until they are cleared on purpose", () => {
|
||||
const ranFinal = { id: "a1", eventId: "event_1", name: "A final 1", type: "final", generated: true, status: "finished" };
|
||||
const readyFinal = { id: "a2", eventId: "event_1", name: "A final 2", type: "final", generated: true, status: "ready" };
|
||||
const state = { sessions: [ranFinal, readyFinal], resultsBySession: { a1: { competitors: { x: { laps: 12 } } } } };
|
||||
let cleared = 0;
|
||||
const created = generateFinalsForRace({ id: "event_1", raceConfig: {} }, {
|
||||
buildPracticeStandings: () => [],
|
||||
buildQualifyingStandings: () => [{ driverId: "d1" }, { driverId: "d2" }],
|
||||
clearGeneratedFinals: () => { cleared += 1; },
|
||||
state, normalizeStartMode, normalizeSession: (session) => session, uid: createUid(), chunkArray, t: (key) => key,
|
||||
});
|
||||
assert.equal(created, 0);
|
||||
assert.equal(cleared, 0, "the run A final 1 and its laps are kept");
|
||||
assert.deepEqual(state.sessions.map((session) => session.id), ["a1", "a2"]);
|
||||
// A heat reset to ready that still holds laps counts as run too; other events and hand-made heats don't.
|
||||
const sessions = [{ ...ranFinal, status: "ready" }, readyFinal, { ...ranFinal, id: "o", eventId: "other" }, { ...ranFinal, id: "m", generated: false }];
|
||||
assert.deepEqual(getRunGeneratedSessions(sessions, "event_1", "final", state.resultsBySession).map((session) => session.id), ["a1"]);
|
||||
assert.deepEqual(getRunGeneratedSessions([readyFinal], "event_1", "final", {}), []);
|
||||
});
|
||||
Reference in new issue
Block a user