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
@@ -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