feat(results): qualifying place (TQ) next to final results and podium bands for the top three (1.74.0)

This commit is contained in:
larssand committed 2026-11-06 23:31:09 +01:00
1 parent 41043a990d
commit fee9f8073d
12 files changed
+149 -38

No files matched your search

+9
View File
@@ -30,3 +30,12 @@ test("places 1-3 get gold, silver and bronze medals - in the app tables and draw
assert.ok(pdf.includes("0.941 0.773 0.247 rg") && pdf.includes("0.812 0.835 0.863 rg") && pdf.includes("0.827 0.541 0.298 rg"), "gold, silver and bronze medal faces");
assert.ok(pdf.includes("(4) Tj"), "place 4 stays a plain number");
});
test("A-final places 1-3 also get medals, and TQ stands out", async () => {
const { medal, qualCell } = await import("../src/medal.js");
assert.equal(medal("A2"), '<span class="medal medal-2">A2</span>');
assert.equal(medal("B1"), "B1");
assert.match(qualCell("TQ", (v) => v), /tq-badge/);
const pdf = buildStyledPdf({ ...base, sections: [{ title: "", headers: ["Pos", "Kval", "Förare"], rows: [["A1", "4", "Al"], ["A2", "TQ", "Bea"]] }] }).toString("latin1");
assert.ok(pdf.includes("(A1) Tj") && pdf.includes("/F2 9 Tf") && pdf.includes("(TQ) Tj"));
});
+19 -3
View File
@@ -1,6 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
import { buildRaceOverview, buildRaceOverviewCsvRows } from "../src/race_overview_logic.js";
import { buildRaceOverview, buildRaceOverviewCsvRows, qualifyingPlaces } from "../src/race_overview_logic.js";
const sessions = [
{ id: "p1", type: "practice", status: "finished", name: "Practice G1", carAssignments: { d1: "c1", d2: "c2" } },
@@ -39,8 +39,8 @@ test("CSV has the standings and every heat row", () => {
const overview = buildRaceOverview({ id: "e1", name: "Cup" }, deps);
const rows = buildRaceOverviewCsvRows(overview, { t: (key) => key, formatLap: (ms) => (ms / 1000).toFixed(3), phaseLabel: (type) => type });
assert.equal(rows[0][0], "event");
assert.deepEqual(rows[1], ["Cup", "practice", "race_overview.total", "1", "Bea", "", "", "17.180", ""]);
assert.deepEqual(rows[2], ["Cup", "practice", "Practice G1", "1", "Bea", "Hyrbil 2", "10", "10/3:01.200", "17.180"]);
assert.deepEqual(rows[1], ["Cup", "practice", "race_overview.total", "1", "", "Bea", "", "", "17.180", ""]);
assert.deepEqual(rows[2], ["Cup", "practice", "Practice G1", "1", "", "Bea", "Hyrbil 2", "10", "10/3:01.200", "17.180"]);
assert.equal(rows.length, 6);
});
@@ -55,3 +55,19 @@ test("results archive groups heats per event, newest event first, A final winner
]);
assert.deepEqual(groups.map((group) => [group.key, group.rows.length, group.winnerName, group.driverCount]), [["e1", 2, "Al", 1], ["session:x", 1, "", 0]]);
});
test("finals show each driver's qualifying place, with TQ for the top qualifier", () => {
assert.deepEqual([...qualifyingPlaces([{ driverId: "d1", rank: 1 }, { driverId: "d2", rank: 2 }])], [["d1", "TQ"], ["d2", "2"]]);
const finalSessions = sessions.map((session) => (session.id === "f1" ? { ...session, status: "finished" } : session));
const overview = buildRaceOverview({ id: "e1", name: "Cup" }, {
...deps,
sessions: finalSessions,
buildLeaderboard: (session) => (session.id === "f1" ? [{ driverId: "d2", displayName: "Bea", laps: 5 }, { driverId: "d1", displayName: "Al", laps: 5 }] : leaderboards[session.id] || []),
buildQualifyingStandings: () => [{ driverId: "d1", rank: 1 }, { driverId: "d2", rank: 2 }],
buildFinalStandings: () => [{ rank: "A1", driverId: "d2", driverName: "Bea" }, { rank: "A2", driverId: "d1", driverName: "Al" }],
});
const finals = overview.phases.find((phase) => phase.type === "final");
assert.deepEqual(finals.heats[0].rows.map((row) => [row.pos, row.name, row.qual]), [[1, "Bea", "2"], [2, "Al", "TQ"]]);
assert.deepEqual(finals.standings.map((row) => [row.rank, row.qual]), [["A1", "2"], ["A2", "TQ"]]);
assert.equal(overview.phases.find((phase) => phase.type === "practice").heats[0].rows[0].qual, "", "only finals get the column");
});