feat(series): run each round from the series page
Step 3 becomes a rounds table: pick drivers inline (copy from the previous round, add a late entry), set qualifying rounds/finals/max cars per heat per round, see the status, and create qualifying and finals from there. Qualifying heats are now split evenly so nobody drives alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,3 +105,25 @@ test("each chosen class gets its own table; events of other classes are ignored"
|
||||
});
|
||||
assert.deepEqual(tables.map((table) => [table.className, table.rows.map((entry) => entry.driverId).join(",")]), [["2WD", "a"], ["4WD", "a,b"]]);
|
||||
});
|
||||
|
||||
test("round status follows the race's sessions", async () => {
|
||||
const { getSeriesRoundStatus } = await import("../src/series_logic.js");
|
||||
const q = (status) => ({ type: "qualification", status });
|
||||
const f = (status) => ({ type: "final", status });
|
||||
assert.equal(getSeriesRoundStatus([]), "not_started");
|
||||
assert.equal(getSeriesRoundStatus([q("ready"), q("ready")]), "qual_ready");
|
||||
assert.equal(getSeriesRoundStatus([q("finished"), q("ready")]), "qual_running");
|
||||
assert.equal(getSeriesRoundStatus([q("finished"), q("finished")]), "qual_done");
|
||||
assert.equal(getSeriesRoundStatus([q("finished"), f("ready")]), "finals");
|
||||
assert.equal(getSeriesRoundStatus([q("finished"), f("finished")]), "done");
|
||||
});
|
||||
|
||||
test("qualifying heats are split as evenly as possible - the heat count follows the field", async () => {
|
||||
const { splitIntoBalancedGroups } = await import("../src/event_race_logic.js");
|
||||
const sizes = (n, max) => splitIntoBalancedGroups(Array.from({ length: n }, (_, i) => i), max).map((group) => group.length);
|
||||
assert.deepEqual(sizes(9, 8), [5, 4], "never 8 + 1");
|
||||
assert.deepEqual(sizes(6, 6), [6]);
|
||||
assert.deepEqual(sizes(13, 6), [5, 4, 4]);
|
||||
assert.deepEqual(sizes(0, 6), []);
|
||||
assert.deepEqual(splitIntoBalancedGroups(["a", "b", "c", "d", "e"], 3), [["a", "b", "c"], ["d", "e"]], "order is kept");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user