add more stats to mobile profile

This commit is contained in:
larssand
2026-09-04 16:17:45 +02:00
parent 142c45be04
commit 4068cc7c19
13 changed files with 267 additions and 22 deletions

View File

@@ -124,6 +124,22 @@ test("public profile contains only the selected driver's sanitized aggregates",
assert.equal(serialized.includes("secret-decoder"), false);
});
test("public profile visibility removes disabled sections from the API payload", () => {
const state = buildState();
state.training.shares[0].visibility = { progress: false, achievements: false, performance: false, goals: false, history: false };
const profile = buildPublicTrainingProfile(state, DRIVER_ONE_TOKEN, "");
const classProfile = profile.classProfiles[0];
assert.deepEqual(profile.visibility, { progress: false, achievements: false, performance: false, goals: false, history: false });
assert.equal(classProfile.goals.length, 0);
assert.deepEqual(classProfile.channelStats, {});
assert.equal("paceHistory" in classProfile.stats, false);
assert.equal("achievements" in classProfile.stats, false);
assert.equal("stintSummaries" in classProfile.stats, false);
assert.equal("dailySummaries" in classProfile.stats, false);
assert.equal(classProfile.stats.totalLaps, 4);
assert.equal(classProfile.stats.bestLapMs, 16000);
});
test("public profile exposes only class-scoped development trends and achievements", () => {
const now = Date.now();
const state = buildState(now);

View File

@@ -43,7 +43,7 @@ test("normalization removes invalid and duplicate training records", () => {
{ id: "lap_anonymous", sourceKey: "source_3", driverId: "", lapMs: 18000, timestamp: 4000 },
],
shares: [
{ driverId: "driver_1", token: "a".repeat(24), enabled: true },
{ driverId: "driver_1", token: "a".repeat(24), enabled: true, visibility: { history: false } },
{ driverId: "driver_1", token: "b".repeat(24), enabled: true },
{ driverId: "driver_2", token: "short", enabled: true },
],
@@ -65,6 +65,7 @@ test("normalization removes invalid and duplicate training records", () => {
assert.equal(normalized.goals[0].reward, "Badge");
assert.deepEqual(normalized.ledger.map((lap) => lap.id), ["lap_1"]);
assert.deepEqual(normalized.shares.map((share) => share.token), ["a".repeat(24)]);
assert.deepEqual(normalized.shares[0].visibility, { progress: true, achievements: true, performance: true, goals: true, history: false });
assert.equal(normalized.markers.length, 1);
assert.equal(normalized.markers[0].note, "New tires");
assert.equal(normalized.clubGoal.title, "Club to 10000");