feat(export): lap times table with best and fastest laps marked in a heat's print and PDF (1.89.52)

This commit is contained in:
larssand committed 2026-11-16 23:18:31 +01:00
1 parent fbc4246a60
commit afe884d2fe
12 files changed
+141 -7

No files matched your search

+18
View File
@@ -62,3 +62,21 @@ test("the PDF draws the lap chart as coloured lines with the names", () => {
assert.ok(pdf.includes("(1. Anna) Tj") && pdf.includes("(2. Bo) Tj"));
assert.ok(pdf.includes("0.902 0.224 0.275 RG"), "the first driver's red line");
});
test("lap table: a column per driver in order, each driver's best lap and the heat's fastest", async () => {
const { buildLapTable } = await import("../src/lap_chart_logic.js");
const table = buildLapTable([{ name: "A", laps: [18000, 17500, 17900] }, { name: "B", laps: [17400, 18100] }]);
assert.deepEqual(table.names, ["A", "B"]);
assert.deepEqual(table.rows, [[18000, 17400], [17500, 18100], [17900, null]]);
assert.deepEqual(table.best, [1, 0]);
assert.deepEqual(table.fastest, { row: 0, col: 1 });
assert.equal(buildLapTable([{ name: "A", laps: [] }]), null);
});
test("lap table: the PDF draws the times with the best laps bold", () => {
const lapTable = { title: "Varvtider", lapLabel: "Varv", legend: "Fet = bästa", names: ["Anna", "Bo"], rows: [["17.400", "18.100"], ["17.900", "17.600"]], best: [0, 1], fastest: { row: 0, col: 0 } };
const pdf = buildStyledPdf({ title: "R", subtitle: "", brandName: "K", brandTagline: "", footer: "", theme: "classic", logoDataUrl: "", sections: [{ title: "Q1 H1", headers: ["Pos", "Förare"], rows: [["1", "Anna"], ["2", "Bo"]], lapTable }] }).toString("latin1");
assert.match(pdf, /Varvtider/);
assert.match(pdf, /\/F2 [\d.]+ Tf [\d.]+ [\d.]+ Td \(17\.400\)/, "fastest lap in bold");
assert.match(pdf, /\/F1 [\d.]+ Tf [\d.]+ [\d.]+ Td \(18\.100\)/, "an ordinary lap in regular");
});