feat(race): federation-style race day presets - EFRA off-road/touring/nitro, ROAR, quick club day, rookie/junior, points only (1.89.34)

This commit is contained in:
larssand committed 2026-11-14 21:54:51 +01:00
1 parent cc286165df
commit 1348b9b57e
13 files changed
+163 -9

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import test from "node:test";
import assert from "node:assert/strict";
import { getRaceFormatPresets, applyRaceWizardPresetDefaults, HEAT_ORDERS } from "../src/event_race_logic.js";
const presets = getRaceFormatPresets({ state: { settings: {} }, t: (key) => key, uid: () => "x", normalizeStoredRacePreset: (p) => p });
const get = (id) => presets.find((preset) => preset.id === id);
test("the federation-style presets are offered with a description", () => {
for (const id of ["efra_offroad", "efra_touring", "efra_nitro", "ifmar", "roar", "club_quick", "rookie_junior", "points_only"]) {
assert.ok(get(id), id);
assert.equal(get(id).hint, `events.preset_${id}_hint`);
}
});
test("every built-in preset has values the race settings accept", () => {
for (const preset of presets.filter((item) => item.id !== "custom")) {
const v = preset.values;
assert.ok(["points", "best"].includes(v.qualifyingScoring), preset.id);
assert.ok(["rank_low", "field_desc", "ifmar"].includes(v.qualifyingPointsTable), preset.id);
assert.ok(["rounds", "best_lap", "best_round"].includes(v.qualifyingTieBreak), preset.id);
assert.ok(["best_sum", "average", "consecutive"].includes(v.qualSeedMethod), preset.id);
assert.ok(!v.heatOrder || HEAT_ORDERS.includes(v.heatOrder), preset.id);
assert.ok(v.countedQualRounds <= v.qualifyingRounds, `${preset.id} counted rounds`);
assert.ok(v.countedFinalLegs <= v.finalLegs, `${preset.id} counted legs`);
assert.ok(v.bumpCount < v.carsPerFinal, `${preset.id} bump-up`);
assert.ok(v.minLapMs < v.maxLapMs, `${preset.id} lap limits`);
}
});
test("a preset sets the wizard's practice rounds; others keep the draft's", () => {
const getRaceWizardPreset = (id) => get(id);
assert.equal(applyRaceWizardPresetDefaults({ practiceSessions: 1 }, "efra_offroad", { getRaceWizardPreset }).practiceSessions, 2);
const draft = applyRaceWizardPresetDefaults({ practiceSessions: 3 }, "club_qualifying", { getRaceWizardPreset });
assert.equal(draft.practiceSessions, 3);
assert.equal(draft.createPractice, true);
assert.equal(applyRaceWizardPresetDefaults({}, "efra_nitro", { getRaceWizardPreset }).qualifyingRounds, 5);
assert.equal(applyRaceWizardPresetDefaults({}, "endurance", { getRaceWizardPreset }).createPractice, false);
});
+1
View File
@@ -11,6 +11,7 @@ import "./team_race_logic.test.js";
import "./race_overview.test.js";
import "./lap_chart.test.js";
import "./participant_picker.test.js";
import "./race_presets.test.js";
import "./leader_call_logic.test.js";
import "./decoder_sim.test.js";
import "./sponsor_event.test.js";