feat(race): optional check-in tab with present, paid, transponder seen and remove no-shows (1.89.29)
This commit is contained in:
1 parent
e98abd92d9
commit
2db77fe6cd
15 files changed
+260
-3
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { normalizeCheckIn, checkInRows, checkInSummary, canRemoveNoShows, removeNoShows } from "../src/check_in_logic.js";
|
||||
|
||||
const drivers = [{ id: "d1", name: "Roy", transponder: "111", classId: "c" }, { id: "d2", name: "Anders", transponder: "222", classId: "c" }, { id: "d3", name: "Helin", transponder: "", classId: "c" }];
|
||||
|
||||
test("rows: present, paid and the transponder seen on the decoder since the morning", () => {
|
||||
const sightings = new Map([["111", { lastSeenAt: 5000 }], ["222", { lastSeenAt: 100 }]]);
|
||||
const rows = checkInRows({ participants: drivers, checkIn: { d1: { present: true, paid: true }, d3: { paid: true }, bad: "x" }, sightings, seenSince: 1000 });
|
||||
assert.deepEqual(rows.map((row) => [row.name, row.present, row.paid, row.seen]), [["Anders", false, false, false], ["Helin", false, true, false], ["Roy", true, true, true]]);
|
||||
assert.deepEqual(checkInSummary(rows), { total: 3, present: 1, paid: 2, seen: 1 });
|
||||
assert.deepEqual(normalizeCheckIn({ d1: { present: false, paid: false }, d2: { present: true } }), { d2: { present: true, paid: false } });
|
||||
});
|
||||
|
||||
test("no-shows leave the race and its heats not yet run, not the register; only before qualifying starts", () => {
|
||||
const state = {
|
||||
drivers,
|
||||
events: [{ id: "e", raceConfig: { driverIds: ["d1", "d2", "d3"], checkIn: { d1: { present: true }, d3: { present: true } } } }],
|
||||
sessions: [
|
||||
{ id: "p", eventId: "e", type: "open_practice", status: "finished", driverIds: ["d1", "d2", "d3"] },
|
||||
{ id: "q", eventId: "e", type: "qualification", status: "ready", driverIds: ["d1", "d2", "d3"], manualGridIds: ["d2", "d1"], assignments: [{ driverId: "d2" }] },
|
||||
],
|
||||
};
|
||||
assert.equal(canRemoveNoShows(state.events[0], state.sessions, state.events[0].raceConfig.checkIn), true, "practice already run is fine");
|
||||
assert.deepEqual(removeNoShows(state, "e"), ["d2"]);
|
||||
assert.deepEqual(state.events[0].raceConfig.driverIds, ["d1", "d3"]);
|
||||
assert.deepEqual(state.sessions[1].driverIds, ["d1", "d3"]);
|
||||
assert.deepEqual(state.sessions[1].manualGridIds, ["d1"]);
|
||||
assert.deepEqual(state.sessions[1].assignments, []);
|
||||
assert.deepEqual(state.sessions[0].driverIds, ["d1", "d2", "d3"], "a heat already run keeps its drivers");
|
||||
assert.equal(state.drivers.length, 3, "still in the register");
|
||||
});
|
||||
|
||||
test("nobody checked in, or qualifying started: nothing is removed", () => {
|
||||
const event = { id: "e", raceConfig: { driverIds: ["d1", "d2"], checkIn: {} } };
|
||||
assert.equal(canRemoveNoShows(event, [], {}), false);
|
||||
const state = { events: [{ ...event, raceConfig: { ...event.raceConfig, checkIn: { d1: { present: true } } } }], sessions: [{ id: "q", eventId: "e", type: "qualification", status: "running" }] };
|
||||
assert.deepEqual(removeNoShows(state, "e"), []);
|
||||
assert.deepEqual(state.events[0].raceConfig.driverIds, ["d1", "d2"]);
|
||||
});
|
||||
Reference in new issue
Block a user