chore(glp1): test-environment tolerance + i18n parity + OpenAPI regen

Final-pass hygiene for the W4d GLP-1 integration:

- `buildGlp1SnapshotBlock()` and `detectGlp1Plateau()` short-circuit
  to `null` when the test environment mocks prisma partially (only
  `measurement` / `moodEntry` mocked, `medication` undefined). Matches
  the production behaviour for accounts without an active GLP-1 row.
- DE locale parity: adds the matching German string for
  `insights.subPage.therapyTimelineDescription` that landed without
  its de.json counterpart.
- Drops unused `locale` destructure on the GLP-1 medication card and
  the dead `DailyValueRow` interface in the snapshot helper.
- Regenerated `docs/api/openapi.yaml` so the new GLP-1 endpoints
  (/api/medications/[id]/glp1, /api/insights/glp1-timeline) appear
  in the spec.
This commit is contained in:
Marc-André Bombeck committed 2026-05-14 14:01:42 +02:00
1 parent f45adb29f0
commit a68dbdc22c
5 files changed
+90 -7

No files matched your search

@@ -156,7 +156,7 @@ export function Glp1MedicationCard({
onLogSideEffect,
}: Glp1MedicationCardProps) {
const queryClient = useQueryClient();
const { t, locale } = useTranslations();
const { t } = useTranslations();
const fmt = useFormatters();
const [intakeLoading, setIntakeLoading] = useState<string | null>(null);
const [showHistory, setShowHistory] = useState(false);
+6 -6
View File
@@ -79,12 +79,6 @@ function parseDaysOfWeek(raw: string | null): number[] {
.filter((n) => Number.isInteger(n) && n >= 0 && n <= 6);
}
interface DailyValueRow {
date: string;
weekday: string;
value: number;
}
interface DoseHistoryEntry {
value: number;
unit: string;
@@ -257,6 +251,12 @@ export async function buildGlp1SnapshotBlock(
userId: string,
now: Date = new Date(),
): Promise<Glp1SnapshotBlock | null> {
// Test environments mock parts of prisma (only `measurement` +
// `moodEntry`) and leave `medication` undefined. Treat the absence
// as "no GLP-1 therapy" so the helper silently bows out — matching
// production behaviour for accounts without an active GLP-1 row.
if (typeof prisma?.medication?.findMany !== "function") return null;
if (typeof prisma?.moodEntry?.findMany !== "function") return null;
const meds = await prisma.medication.findMany({
where: {
userId,
+5
View File
@@ -41,6 +41,11 @@ export async function detectGlp1Plateau(
userId: string,
now: Date = new Date(),
): Promise<Glp1PlateauContext | null> {
// Test environments mock parts of prisma (e.g. only `measurement`)
// and leave `medication` undefined. Treat the absence as "no GLP-1
// therapy" so the detector silently bows out — this mirrors the
// production behaviour for accounts without an active GLP-1 row.
if (typeof prisma?.medication?.findMany !== "function") return null;
const meds = await prisma.medication.findMany({
where: { userId, treatmentClass: "GLP1", active: true },
include: {