fix tränings länken och race day

This commit is contained in:
larssand
2026-08-28 21:55:28 +02:00
parent 375bfb2416
commit 28e5c96010
7 changed files with 531 additions and 6 deletions

View File

@@ -100,6 +100,7 @@ test("public profile contains only the selected driver's sanitized aggregates",
assert.equal(profile.goals[0].percent, 80);
assert.equal(profile.classProfiles.length, 2);
assert.equal(profile.classProfiles[0].stats.totalLaps, 4);
assert.equal(profile.classProfiles[0].stats.achievements.find((item) => item.id === "first_session").unlocked, true);
assert.deepEqual(profile.classProfiles[0].channelStats, {
splitCount: 2,
bestSplitMs: 7000,
@@ -122,6 +123,26 @@ test("public profile contains only the selected driver's sanitized aggregates",
assert.equal(serialized.includes("secret-decoder"), false);
});
test("public profile exposes only class-scoped development trends and achievements", () => {
const now = Date.now();
const state = buildState(now);
state.training.ledger = Array.from({ length: 60 }, (_, index) => ({
driverId: "driver_1",
sessionId: "practice_2wd",
timestamp: now - (60 - index) * 18_000,
lapMs: index < 30 ? 18_000 : 17_000,
}));
const profile = buildPublicTrainingProfile(state, DRIVER_ONE_TOKEN, "");
const twoWheelDrive = profile.classProfiles.find((item) => item.classId === "class_1");
const fourWheelDrive = profile.classProfiles.find((item) => item.classId === "class_2");
assert.equal(twoWheelDrive.stats.trendSampleReady, true);
assert.equal(twoWheelDrive.stats.averageTrendMs, 1_000);
assert.equal(twoWheelDrive.stats.achievements.find((item) => item.id === "controlled_5").unlocked, true);
assert.equal(fourWheelDrive.stats.totalLaps, 0);
assert.equal(fourWheelDrive.stats.trendSampleReady, false);
});
test("public timer window freezes aggregates after the personal session", () => {
const now = Date.now();
const profile = buildPublicTrainingProfile(buildState(now), DRIVER_ONE_TOKEN, "", now - 30 * 60000, 20 * 60000);