förbättreing tränings

This commit is contained in:
larssand
2026-08-28 21:44:23 +02:00
parent c6262aceab
commit 375bfb2416
14 changed files with 420 additions and 54 deletions

View File

@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
import { getDriverProfileGroups } from "../src/driver_profile_logic.js";
import { buildDriverTrainingStats } from "../src/training_logic.js";
import { buildTrainingOverviewRows, resolveTrainingProfile } from "../src/training_views.js";
import { buildTrainingOverviewRows, buildTrainingProgressFeed, resolveTrainingProfile } from "../src/training_views.js";
test("training opens without implicitly selecting the first driver", () => {
const profiles = [{ id: "profile_1", driverIds: ["driver_1"] }];
@@ -33,3 +33,15 @@ test("training overview keeps each driver class on a separate statistics row", (
assert.equal(rows.find((row) => row.classId === "2wd").stats.totalLaps, 2);
assert.equal(rows.find((row) => row.classId === "4wd").stats.totalLaps, 1);
});
test("training progress feed highlights personal development instead of ranking drivers", () => {
const rows = [
{ profile: { id: "p1" }, driver: { name: "Alex" }, classId: "2wd", className: "2WD", stats: { totalLaps: 80, lastLapAt: 200, personalBestGainMs: 250 } },
{ profile: { id: "p2" }, driver: { name: "Kim" }, classId: "4wd", className: "4WD", stats: { totalLaps: 120, lastLapAt: 100, trendSampleReady: true, averageTrendMs: 400 } },
];
const feed = buildTrainingProgressFeed(rows);
assert.deepEqual(feed.map((entry) => entry.profile.id), ["p1", "p2"]);
assert.equal(feed[0].kind, "personal_best");
assert.equal(feed[1].kind, "average_gain");
});