förbättreing tränings
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
buildDriverActivePracticeStats,
|
||||
buildDriverTrainingStats,
|
||||
buildDriverTimingChannelStats,
|
||||
buildTrainingAchievements,
|
||||
buildTrainingRecommendation,
|
||||
getBestConsecutiveTrainingLaps,
|
||||
getBestTrainingDurationResult,
|
||||
@@ -337,3 +338,36 @@ test("goal and automatic milestone progress are bounded", () => {
|
||||
assert.equal(getNextTrainingMilestone({ totalLaps: 250 }).targetLaps, 500);
|
||||
assert.equal(getNextTrainingMilestone({ totalLaps: 5200 }).targetLaps, 6000);
|
||||
});
|
||||
|
||||
test("development trend compares the latest 30 laps with the preceding 30", () => {
|
||||
const start = new Date(2026, 0, 10, 12, 0, 0).getTime();
|
||||
const ledger = Array.from({ length: 60 }, (_, index) => ({
|
||||
driverId: "driver_1",
|
||||
sessionId: "practice_1",
|
||||
timestamp: start + ((index + 1) * 18_000),
|
||||
lapMs: index < 30 ? 18_000 : 17_000,
|
||||
}));
|
||||
const stats = buildDriverTrainingStats({ training: { ledger } }, "driver_1");
|
||||
|
||||
assert.equal(stats.trendSampleReady, true);
|
||||
assert.equal(stats.previousRecentAverageMs, 18_000);
|
||||
assert.equal(stats.recentAverageMs, 17_000);
|
||||
assert.equal(stats.averageTrendMs, 1_000);
|
||||
assert.equal(stats.consistencyTrendPct, 0);
|
||||
});
|
||||
|
||||
test("automatic achievements expose unlocked and upcoming personal goals", () => {
|
||||
const achievements = buildTrainingAchievements({
|
||||
totalSessions: 2,
|
||||
totalLaps: 520,
|
||||
trainingDays: 4,
|
||||
controlledLapStreak: 7,
|
||||
bestFiveMinuteResult: { lapCount: 17 },
|
||||
});
|
||||
|
||||
assert.equal(achievements.find((item) => item.id === "first_session").unlocked, true);
|
||||
assert.equal(achievements.find((item) => item.id === "laps_500").unlocked, true);
|
||||
assert.equal(achievements.find((item) => item.id === "laps_1000").percent, 52);
|
||||
assert.equal(achievements.find((item) => item.id === "days_10").unlocked, false);
|
||||
assert.equal(achievements.find((item) => item.id === "five_minute").unlocked, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user