fix(analytics): repair route/i18n/guard fallout from health-score merge

This commit is contained in:
Marc-André Bombeck committed 2026-07-28 21:19:18 +02:00
1 parent 7b8fb98e48
commit ff8ead2db9
8 files changed
+19 -69

No files matched your search

-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Im Moment ist alles stabil."
}
},
"tension": {
"label": "Ehrliche Lesung: {positive} sieht gut aus, aber {negative} fällt ab — das Komposit landet bei {band}.",
"contributor": {
"green": "grün",
"yellow": "gelb",
"red": "rot"
}
},
"streak": {
"returnLabel": "Dein {metric} ist seit {count} Tagen wieder in deinem üblichen Bereich — was es auch war, es ist vorbei."
},
"updatedTodayAt": "Heute aktualisiert, {time}",
"updatedYesterday": "Gestern aktualisiert",
"updatedOn": "Aktualisiert am {date}",
-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Everything's holding steady for now."
}
},
"tension": {
"label": "Honest read: {positive} looks good, but {negative} is off — the composite lands {band}.",
"contributor": {
"green": "green",
"yellow": "yellow",
"red": "red"
}
},
"streak": {
"returnLabel": "Your {metric} has been back inside your usual range for {count} days now — whatever that was, it's passed."
},
"updatedTodayAt": "Updated today, {time}",
"updatedYesterday": "Updated yesterday",
"updatedOn": "Updated on {date}",
-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Por ahora todo se mantiene estable."
}
},
"tension": {
"label": "Lectura sincera: {positive} tiene buena pinta, pero {negative} flojea — el conjunto queda en {band}.",
"contributor": {
"green": "verde",
"yellow": "amarillo",
"red": "rojo"
}
},
"streak": {
"returnLabel": "Tu {metric} ha vuelto a tu rango habitual tras {count} días — fuera lo que fuera, ya pasó."
},
"updatedTodayAt": "Actualizado hoy, {time}",
"updatedYesterday": "Actualizado ayer",
"updatedOn": "Actualizado el {date}",
-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Pour l'instant, tout reste stable."
}
},
"tension": {
"label": "Lecture honnête : {positive} se présente bien, mais {negative} décroche — l'ensemble se situe à {band}.",
"contributor": {
"green": "vert",
"yellow": "jaune",
"red": "rouge"
}
},
"streak": {
"returnLabel": "Ton {metric} est de nouveau dans ta plage habituelle après {count} jours — quoi que c'était, c'est passé."
},
"updatedTodayAt": "Mis à jour aujourd'hui, {time}",
"updatedYesterday": "Mis à jour hier",
"updatedOn": "Mis à jour le {date}",
-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Per ora è tutto stabile."
}
},
"tension": {
"label": "Lettura sincera: {positive} ha un bell'aspetto, ma {negative} è in calo — il complessivo si attesta su {band}.",
"contributor": {
"green": "verde",
"yellow": "giallo",
"red": "rosso"
}
},
"streak": {
"returnLabel": "Il tuo {metric} è di nuovo nel tuo intervallo abituale dopo {count} giorni — qualunque cosa fosse, è passata."
},
"updatedTodayAt": "Aggiornato oggi, {time}",
"updatedYesterday": "Aggiornato ieri",
"updatedOn": "Aggiornato il {date}",
-11
View File
@@ -3955,17 +3955,6 @@
"forwardHolding": "Na razie wszystko jest stabilne."
}
},
"tension": {
"label": "Szczera ocena: {positive} wygląda dobrze, ale {negative} odstaje — wynik łączny ląduje na {band}.",
"contributor": {
"green": "zielony",
"yellow": "żółty",
"red": "czerwony"
}
},
"streak": {
"returnLabel": "Twój {metric} wrócił do twojego zwykłego zakresu po {count} dniach — cokolwiek to było, minęło."
},
"updatedTodayAt": "Zaktualizowano dzisiaj, {time}",
"updatedYesterday": "Zaktualizowano wczoraj",
"updatedOn": "Zaktualizowano {date}",
@@ -174,7 +174,6 @@ const PINNED_AFFORDANCES: Record<
"src/components/insights/confidence-badge.ts": { "text-success": 1 },
"src/components/insights/daily-briefing.tsx": { "text-success": 1 },
"src/components/insights/derived/band-tokens.ts": { "text-success": 1 },
"src/components/insights/health-score-card.tsx": { "text-success": 4 },
"src/components/insights/insights-edit-mode.tsx": { "toast.success": 2 },
"src/components/insights/insights-tab-strip.tsx": { "toast.success": 1 },
"src/components/insights/mood/mood-better-days.tsx": { "text-success": 1 },
+19 -2
View File
@@ -28,6 +28,13 @@ vi.mock("@/lib/db", () => ({
moodEntry: { findMany: vi.fn() },
medicationIntakeEvent: { findMany: vi.fn() },
medication: { findMany: vi.fn() },
// v1.34 — the versioned reference score reads these three models
// directly (not through the shared measurement/rollup path); default
// to empty/null so a brand-new-user response doesn't throw before the
// route can even decide the composite is ungraded.
mentalHealthAssessment: { findMany: vi.fn().mockResolvedValue([]) },
labResult: { findMany: vi.fn().mockResolvedValue([]) },
dismissedPriorityItem: { findUnique: vi.fn().mockResolvedValue(null) },
// v1.4.33 C1 — slim summaries slice runs through `$queryRaw`. The
// v1.4.36 per-type coverage probe and the v1.4.37 default-slice
// probe also ride `$queryRaw`. Default to an empty coverage map so
@@ -139,6 +146,13 @@ beforeEach(() => {
[] as never,
);
vi.mocked(prisma.medication.findMany).mockResolvedValue([] as never);
vi.mocked(prisma.mentalHealthAssessment.findMany).mockResolvedValue(
[] as never,
);
vi.mocked(prisma.labResult.findMany).mockResolvedValue([] as never);
vi.mocked(prisma.dismissedPriorityItem.findUnique).mockResolvedValue(
null as never,
);
// v1.4.35 — rollup table defaults. `resetAllMocks` clears the
// module-level implementations, so we re-seed both per test. Empty
// findMany + null findFirst means the slim slice's parity check
@@ -210,13 +224,16 @@ describe("GET /api/analytics", () => {
data: {
summaries: Record<string, { count: number }>;
bmi: number | null;
healthScore: unknown;
healthScore: { composite: { status: string } } | null;
};
};
expect(body.data.summaries.PULSE.count).toBe(0);
expect(body.data.summaries.WEIGHT.count).toBe(0);
expect(body.data.bmi).toBeNull();
expect(body.data.healthScore).toBeNull();
// v1.34 — the versioned reference score always returns a structured
// report, even with zero data; a brand-new user reads as an explicit
// "insufficient" composite, never a bare null.
expect(body.data.healthScore?.composite.status).toBe("insufficient");
// v1.4.49.1 — the legacy 15-way per-type live walk used a chunked
// pagination select `(id, measuredAt, value, source, deviceType)`
// unique to `fetchMeasurementSeriesChunked`. Other `findMany` calls