From b7458f06073d70f9d23e7720a0cd757ddd156dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 3 Oct 2026 21:59:42 +0200 Subject: [PATCH] Stub the custom category read in the export route tests The full backup now reads the account's own medication categories, and three route tests that drive the payload builder against a mocked client had no delegate for it. --- src/app/api/export/__tests__/per-type-routes.test.ts | 6 ++++++ src/app/api/export/__tests__/soft-delete-filter.test.ts | 3 +++ src/app/api/export/encrypted/__tests__/route.test.ts | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/app/api/export/__tests__/per-type-routes.test.ts b/src/app/api/export/__tests__/per-type-routes.test.ts index a6a01a3e6..3fa921aee 100644 --- a/src/app/api/export/__tests__/per-type-routes.test.ts +++ b/src/app/api/export/__tests__/per-type-routes.test.ts @@ -23,6 +23,9 @@ vi.mock("@/lib/db", () => ({ passkey: { count: vi.fn(async () => 0) }, measurement: { findMany: vi.fn() }, medication: { findMany: vi.fn() }, + // v1.40 — the custom medication categories the backup carries. + medicationCategoryLabel: { findMany: vi.fn().mockResolvedValue([]) }, + medicationCategoryAssignment: { findMany: vi.fn().mockResolvedValue([]) }, medicationIntakeEvent: { findMany: vi.fn() }, moodEntry: { findMany: vi.fn() }, moodTag: { findMany: vi.fn() }, @@ -129,6 +132,9 @@ beforeEach(() => { // `resetAllMocks` clears the inline defaults, and the full-backup payload // builder reads these unconditionally. vi.mocked(prisma.nutrientIntakeDay.findMany).mockResolvedValue([] as never); + vi.mocked(prisma.medicationCategoryLabel.findMany).mockResolvedValue( + [] as never, + ); vi.mocked(prisma.userHealthProfile.findUnique).mockResolvedValue( null as never, ); diff --git a/src/app/api/export/__tests__/soft-delete-filter.test.ts b/src/app/api/export/__tests__/soft-delete-filter.test.ts index 45cb98d38..d0d5da720 100644 --- a/src/app/api/export/__tests__/soft-delete-filter.test.ts +++ b/src/app/api/export/__tests__/soft-delete-filter.test.ts @@ -22,6 +22,9 @@ vi.mock("@/lib/db", () => ({ $queryRaw: vi.fn(), measurement: { findMany: vi.fn(), count: vi.fn() }, medication: { findMany: vi.fn() }, + // v1.40 — the custom medication categories the backup carries. + medicationCategoryLabel: { findMany: vi.fn().mockResolvedValue([]) }, + medicationCategoryAssignment: { findMany: vi.fn().mockResolvedValue([]) }, medicationIntakeEvent: { findMany: vi.fn(), count: vi.fn() }, moodEntry: { findMany: vi.fn(), count: vi.fn() }, moodTag: { findMany: vi.fn() }, diff --git a/src/app/api/export/encrypted/__tests__/route.test.ts b/src/app/api/export/encrypted/__tests__/route.test.ts index 3df29eb17..d83552725 100644 --- a/src/app/api/export/encrypted/__tests__/route.test.ts +++ b/src/app/api/export/encrypted/__tests__/route.test.ts @@ -12,6 +12,9 @@ vi.mock("@/lib/db", () => ({ prisma: { measurement: { findMany: vi.fn().mockResolvedValue([]) }, medication: { findMany: vi.fn().mockResolvedValue([]) }, + // v1.40 — the custom medication categories the backup carries. + medicationCategoryLabel: { findMany: vi.fn().mockResolvedValue([]) }, + medicationCategoryAssignment: { findMany: vi.fn().mockResolvedValue([]) }, medicationIntakeEvent: { findMany: vi.fn().mockResolvedValue([]) }, moodEntry: { findMany: vi.fn().mockResolvedValue([]) }, moodTag: { findMany: vi.fn().mockResolvedValue([]) },