fix(profile): open the mobile profile on the class driven last (1.42.3)
Passes and exercises only count the selected class, and the profile opened on the first registered one, so laps with another car never showed. It now opens on the class with the latest lap and offers a switch when today's latest laps are in another class.
This commit is contained in:
1 parent
3eb4b5f042
commit
ca88fd9ecc
9 files changed
+99
-4
No files matched your search
@@ -507,3 +507,16 @@ test("public profile counts practice by default; race laps only with source race
|
||||
assert.equal(stats("all").totalLaps, 6);
|
||||
assert.equal(buildPublicTrainingProfile(state, DRIVER_ONE_TOKEN, "", 0, 0, 0, 0, "current", "bogus").lapSource, "practice");
|
||||
});
|
||||
|
||||
test("each class in a mobile profile carries the time of its latest lap, so the phone opens on the class driven last", () => {
|
||||
const now = Date.now();
|
||||
const state = buildState(now);
|
||||
let profile = buildPublicTrainingProfile(state, DRIVER_ONE_TOKEN, new Date(now).toISOString());
|
||||
const lastLapAt = (classId) => profile.classProfiles.find((item) => item.classId === classId).lastLapAt;
|
||||
assert.equal(lastLapAt("class_1"), now - 4000, "2WD: the 0.5 s non-lap is not a lap");
|
||||
assert.equal(lastLapAt("class_2"), now - 5000);
|
||||
// Out with the 4WD now: it becomes the class driven last.
|
||||
state.training.ledger.push({ driverId: "driver_1_4wd", sessionId: "free", timestamp: now - 1000, lapMs: 14200 });
|
||||
profile = buildPublicTrainingProfile(state, DRIVER_ONE_TOKEN, new Date(now).toISOString());
|
||||
assert.equal(lastLapAt("class_2"), now - 1000);
|
||||
});
|
||||
Reference in new issue
Block a user