feat(series): seeding practice in groups split on the series standings (1.45.0)
This commit is contained in:
1 parent
80e0c5308a
commit
e7eaa0561e
11 files changed
+112
-21
No files matched your search
+11
-4
@@ -90,11 +90,18 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
await waitFor(async () => JSON.stringify([...(await savedState()).events.find((item) => item.id === roundTwo.id).raceConfig.driverIds].sort()) === JSON.stringify([...roundOneIds].sort()), "round 2 copied from round 1");
|
||||
|
||||
// The row's next step is the seeding practice: one click selects it and opens Race Day.
|
||||
assert.equal(await inRound(roundOne.id, `return row.querySelector('[data-round-action="run"]')?.textContent.trim();`), "▶ Seeding practice");
|
||||
await inRound(roundOne.id, `row.querySelector('[data-round-action="run"]').click();`);
|
||||
// Max 2 per seeding group, 3 drivers today: two groups (2 + 1), split when the button is pressed.
|
||||
await inRound(roundOne.id, `const input = row.querySelector('input[name="seedGroupSize"]'); input.value = "2"; input.dispatchEvent(new Event("change"));`);
|
||||
await waitFor(async () => (await savedState()).events.find((item) => item.id === roundOne.id).raceConfig.seedGroupSize === 2, "seed group size saved");
|
||||
await waitFor(async () => (await inRound(roundOne.id, `return row.querySelector('[data-round-action="seeding"]')?.textContent.trim();`)) === "▶ Seeding practice (2 groups)", "button says how many groups");
|
||||
await inRound(roundOne.id, `row.querySelector('[data-round-action="seeding"]').click();`);
|
||||
await waitFor(async () => (await evaluate(`new URL(location.href).searchParams.get("view")`)) === "race_day", "Race Day opened");
|
||||
const practiceId = (await savedState()).sessions.find((session) => session.eventId === roundOne.id && session.type === "practice").id;
|
||||
await waitFor(async () => (await savedState()).activeSessionId === practiceId, "seeding practice is the active session");
|
||||
const seedingGroups = async () => (await savedState()).sessions.filter((session) => session.eventId === roundOne.id && session.type === "practice");
|
||||
await waitFor(async () => (await seedingGroups()).length === 2, "seeding split into two groups");
|
||||
const groups = await seedingGroups();
|
||||
assert.deepEqual(groups.map((session) => [session.name, session.driverIds.length]), [["Seeding practice 1", 1], ["Seeding practice 2", 2]], "fastest group last: the 2 at the top of the order run second");
|
||||
const practiceId = groups[0].id;
|
||||
await waitFor(async () => (await savedState()).activeSessionId === practiceId, "first seeding group is the active session");
|
||||
assert.ok(await evaluate(`Boolean(document.getElementById("raceDayStart"))`), "only Start is left to press");
|
||||
await navigate("series", "seriesNew");
|
||||
await evaluate(`document.querySelector('[data-series-select="${saved.id}"]')?.click()`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { orderSessionsForRunning } from "../src/event_race_logic.js";
|
||||
import { orderSessionsForRunning, planSeedingGroups } from "../src/event_race_logic.js";
|
||||
import { getSeriesRoundNextStep } from "../src/series_logic.js";
|
||||
import { buildRaceDayQueue } from "../src/race_day_logic.js";
|
||||
|
||||
@@ -22,7 +22,8 @@ test("Race Day's next heat follows the running order", () => {
|
||||
});
|
||||
|
||||
test("a series round's next step walks seeding -> qualifying -> heats -> finals -> done", () => {
|
||||
assert.deepEqual(getSeriesRoundNextStep([s("Seeding", "practice")]), { kind: "seeding", session: s("Seeding", "practice") });
|
||||
assert.deepEqual(getSeriesRoundNextStep([s("Seeding", "practice")]), { kind: "seeding", session: s("Seeding", "practice"), notStarted: true });
|
||||
assert.deepEqual(getSeriesRoundNextStep([s("Seeding 1", "practice", "finished"), s("Seeding 2", "practice")]), { kind: "seeding", session: s("Seeding 2", "practice"), notStarted: false });
|
||||
assert.deepEqual(getSeriesRoundNextStep([s("Seeding", "practice", "finished")]), { kind: "make_qualifying" });
|
||||
assert.equal(getSeriesRoundNextStep([s("Seeding", "practice", "running")]).kind, "live");
|
||||
const quals = [s("Q2 H1", "qualification"), s("Q1 H1", "qualification", "finished"), s("Q1 H2", "qualification")];
|
||||
@@ -31,3 +32,13 @@ test("a series round's next step walks seeding -> qualifying -> heats -> finals
|
||||
assert.equal(getSeriesRoundNextStep([s("Q1 H1", "qualification", "finished"), s("A Final 1", "final"), s("B Final 1", "final")]).session.name, "B Final 1");
|
||||
assert.deepEqual(getSeriesRoundNextStep([s("Q1 H1", "qualification", "finished"), s("A Final 1", "final", "finished")]), { kind: "done" });
|
||||
});
|
||||
|
||||
test("seeding groups: even split by max size, top of the standings last with fastest-last", () => {
|
||||
const ids = Array.from({ length: 10 }, (_, index) => `d${index + 1}`);
|
||||
assert.deepEqual(planSeedingGroups(ids, 5, "fastest_first"), [ids.slice(0, 5), ids.slice(5)]);
|
||||
assert.deepEqual(planSeedingGroups(ids, 5, "fastest_last"), [ids.slice(5), ids.slice(0, 5)]);
|
||||
assert.deepEqual(planSeedingGroups(ids.slice(0, 6), 3, "fastest_first").map((group) => group.length), [3, 3]);
|
||||
assert.deepEqual(planSeedingGroups(ids, 0, "fastest_first"), [ids], "0 = everyone together");
|
||||
const fifty = Array.from({ length: 50 }, (_, index) => `x${index}`);
|
||||
assert.deepEqual(planSeedingGroups(fifty, 6, "fastest_first").map((group) => group.length), [6, 6, 6, 6, 6, 5, 5, 5, 5]);
|
||||
});
|
||||
Reference in new issue
Block a user