feat(houseofrc): preview and send results to the event's entries, heats or final placings (1.83.0)
This commit is contained in:
1 parent
f4a62b92d2
commit
ebdc6104e6
17 files changed
+295
-15
No files matched your search
@@ -105,3 +105,37 @@ test("House of RC re-fetch: late entries are added, withdrawn ones offered for r
|
||||
assert.equal(drivers.find((driver) => driver.id === "late").transponder, "9");
|
||||
assert.deepEqual(diffHouseOfRcEntries({ ...event, raceConfig: { driverIds: ids } }, entries, drivers), { added: [], withdrawn: [] }, "fetching again finds nothing new");
|
||||
});
|
||||
|
||||
test("House of RC results: heats and qualifying without placings, then final placings by main", async () => {
|
||||
const { buildHouseOfRcResults, formatHouseOfRcTime } = await import("../src/houseofrc_logic.js");
|
||||
assert.deepEqual([formatHouseOfRcTime(13201), formatHouseOfRcTime(303412), formatHouseOfRcTime(0)], ["13.201", "5:03.412", ""]);
|
||||
const event = { raceConfig: { driverIds: ["a", "b", "h"] }, houseOfRc: { eventId: 1, entryIds: { a: 11, b: 12, gone: 13 } } };
|
||||
const drivers = [{ id: "a", name: "Anna" }, { id: "b", name: "Bo" }, { id: "h", name: "Hand Added" }];
|
||||
const heat = (name, rows) => ({ session: { name }, rows });
|
||||
const overview = { phases: [
|
||||
{ type: "qualification", standings: [{ driverId: "b", rank: 1 }, { driverId: "a", rank: 2 }], heats: [
|
||||
heat("Kval 1", [{ pos: 1, driverId: "b", laps: 12, timeMs: 300500, bestLapMs: 13201 }, { pos: 2, driverId: "a", laps: 11, timeMs: 301000, bestLapMs: 14002 }]),
|
||||
] },
|
||||
{ type: "final", standings: [{ driverId: "a", rank: "A1" }, { driverId: "b", rank: "A2" }], heats: [
|
||||
heat("A-final", [{ pos: 1, driverId: "a", laps: 22, timeMs: 303412, bestLapMs: 12950 }, { pos: 2, driverId: "b", laps: 21, timeMs: 0, bestLapMs: 13100, raceStatus: "dnf" }]),
|
||||
] },
|
||||
] };
|
||||
const live = buildHouseOfRcResults(event, overview, { drivers });
|
||||
assert.deepEqual(live.missing, ["Hand Added"], "a hand-added driver has no entry to write to");
|
||||
assert.deepEqual(live.entries.map((entry) => entry.id), [11, 12], "only participants; a removed driver's entry is not sent");
|
||||
assert.ok(live.entries.every((entry) => !("ranking" in entry)), "no placing yet, so nobody is notified");
|
||||
const bo = live.entries[1];
|
||||
assert.equal(bo.qualification, 1);
|
||||
assert.equal(bo.tq, true);
|
||||
assert.deepEqual(bo.data.result.heats[1], { heat: "A-final", laps: 21, time: "DNF", best_lap: "13.100", position: 2 });
|
||||
assert.equal(bo.data.result.best_lap, "13.100");
|
||||
const done = buildHouseOfRcResults(event, overview, { final: true, drivers });
|
||||
assert.deepEqual(done.entries.map((entry) => [entry.id, entry.ranking, entry.data.result.main, entry.data.result.main_position]), [[11, 1, "A", 1], [12, 2, "A", 2]]);
|
||||
assert.equal(done.entries[0].laps_time, "22/5:03.412");
|
||||
assert.deepEqual(done.rows.map((row) => row.name), ["Anna", "Bo"], "preview in final order");
|
||||
const bumped = { phases: [{ type: "final", standings: [{ driverId: "b", rank: "A1" }, { driverId: "a", rank: "A2" }, { driverId: "h", rank: "B1" }, { driverId: "b", rank: "B2" }], heats: [] }] };
|
||||
const withBump = buildHouseOfRcResults({ ...event, houseOfRc: { entryIds: { a: 11, b: 12, h: 13 } } }, bumped, { final: true, drivers });
|
||||
assert.deepEqual(withBump.entries.map((entry) => [entry.id, entry.ranking, entry.data.result.main, entry.data.result.bumped_from]), [[11, 2, "A", undefined], [12, 1, "A", ["B"]], [13, 3, "B", undefined]], "a bumped driver counts once, in the higher main");
|
||||
const noQual = buildHouseOfRcResults(event, { phases: [] }, { drivers });
|
||||
assert.ok(!("qualification" in noQual.entries[0]), "before any qualifying, House of RC's value is left alone");
|
||||
});
|
||||
Reference in new issue
Block a user