feat(race-setup): list sessions in running order and move them with up/down (1.49.0)
This commit is contained in:
1 parent
e199f3aa1a
commit
bb0fa7ede4
14 files changed
+104
-14
No files matched your search
@@ -84,4 +84,27 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState,
|
||||
await click("team-delete-" + team.id);
|
||||
await waitFor(async () => !(await raceState()).raceConfig.teams.some(item => item.id === team.id), "team deletion");
|
||||
console.log("PASS race wizard/edit/reload, team create/member-edit/delete, session type/duration and lap limits");
|
||||
|
||||
// Running order: the sessions are listed in it, and ▲ moves one earlier.
|
||||
for (const name of ["Q1 H2", "Q1 H1"]) {
|
||||
await fill("sessionForm", { name, type: "qualification", durationMin: "5" });
|
||||
await submit("sessionForm");
|
||||
await waitFor(async () => (await savedState()).sessions.some((item) => item.name === name), name + " created");
|
||||
}
|
||||
const listed = async () => evaluate(`[...document.querySelectorAll("[data-session-move][data-step='1']")].map((button) => button.dataset.sessionMove)`);
|
||||
const sessionNames = async () => {
|
||||
const ids = await listed();
|
||||
const all = (await savedState()).sessions;
|
||||
return ids.map((id) => all.find((item) => item.id === id)?.name).filter((name) => /^Q1/.test(name));
|
||||
};
|
||||
await waitFor(async () => (await sessionNames()).join() === "Q1 H1,Q1 H2", "listed in running order although Q1 H1 was made last");
|
||||
const q12 = (await savedState()).sessions.find((item) => item.name === "Q1 H2");
|
||||
await evaluate(`document.querySelector('[data-session-move="${q12.id}"][data-step="-1"]').click()`);
|
||||
await waitFor(async () => (await sessionNames()).join() === "Q1 H2,Q1 H1", "Q1 H2 moved up");
|
||||
const q11 = (await savedState()).sessions.find((item) => item.name === "Q1 H1");
|
||||
await waitFor(async () => {
|
||||
const order = (await raceState()).sessionOrder || [];
|
||||
return order.includes(q12.id) && order.indexOf(q12.id) < order.indexOf(q11.id);
|
||||
}, "the order is saved on the race");
|
||||
console.log("PASS Race Setup lists sessions in running order and ▲▼ change it");
|
||||
}
|
||||
@@ -52,3 +52,19 @@ test("a round's hand-set result replaces the calculated one in the standings", a
|
||||
assert.deepEqual(getSeriesDayResult(series, "e1", calculated, (id) => names[id]).map((row) => row.driverName), ["Roy Gjemble", "Wilmer Nilsson"]);
|
||||
assert.equal(getSeriesDayResult(series, "e2", calculated), calculated, "no hand-set order: the calculated result");
|
||||
});
|
||||
|
||||
test("running order: a recreated heat keeps its place, and ▲▼ set an order of your own", async () => {
|
||||
const { moveSessionInRunningOrder } = await import("../src/event_race_logic.js");
|
||||
const s = (id, name, type = "qualification") => ({ id, name, type });
|
||||
// Q1 H2 was deleted and made again: it is last in the list but runs after Q1 H1.
|
||||
const sessions = [s("p", "Seeding practice", "practice"), s("q11", "Q1 H1"), s("q21", "Q2 H1"), s("q22", "Q2 H2"), s("a1", "A Final 1", "final"), s("q12", "Q1 H2")];
|
||||
const names = (list) => list.map((item) => item.name);
|
||||
assert.deepEqual(names(orderSessionsForRunning(sessions)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H1", "Q2 H2", "A Final 1"]);
|
||||
// Move Q2 H2 before Q2 H1.
|
||||
const manual = moveSessionInRunningOrder(sessions, [], "q22", -1);
|
||||
assert.deepEqual(names(orderSessionsForRunning(sessions, manual)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H2", "Q2 H1", "A Final 1"]);
|
||||
// A session made afterwards (not in the manual order) still gets its own place.
|
||||
const more = [...sessions, s("q31", "Q3 H1")];
|
||||
assert.deepEqual(names(orderSessionsForRunning(more, manual)), ["Seeding practice", "Q1 H1", "Q1 H2", "Q2 H2", "Q2 H1", "Q3 H1", "A Final 1"]);
|
||||
assert.deepEqual(moveSessionInRunningOrder(sessions, manual, "p", -1), manual, "the first can't move up");
|
||||
});
|
||||
Reference in new issue
Block a user