test(insights): stub briefing illness/cycle context in generate route test

The v1.18.11 briefing now folds illness-episode and cycle state into the
prompt via buildBriefingIllnessCycleContext, which resolves module gates
through memoizePerRequest and queries cycleProfile. The generate route test
mocks neither getEvent nor the cycle/illness models, so every case threw once
the new call path ran. Stub the context module to no output and add the
getEvent export to the logging-context mock so these cases stay scoped to the
provider and cache behaviour they assert.
This commit is contained in:
Marc-André Bombeck committed 2026-06-21 01:02:44 +02:00
1 parent 5666e63a57
commit 85828371a6
1 file changed
+14
@@ -103,6 +103,20 @@ vi.mock("@/lib/insights/comprehensive-generate", () => ({
vi.mock("@/lib/logging/context", () => ({
annotate: vi.fn(),
// The briefing illness/cycle context resolves module gates through
// `memoizePerRequest`, which reads the active wide-event via `getEvent`.
// Returning no event makes the per-request cache fall through to the
// factory, exercising the real gate path without a request scope.
getEvent: vi.fn(() => undefined),
}));
// The briefing's illness/cycle context (v1.18.11 P5) is module-gated and
// server-authoritative with its own gate tests; these cases exercise the
// provider/cache path, so stub it to no context to keep the route isolated
// from the cycle/illness DB queries.
vi.mock("@/lib/insights/illness-cycle-briefing", () => ({
buildBriefingIllnessCycleContext: vi.fn(async () => null),
buildBriefingIllnessCyclePrompt: vi.fn(() => ""),
}));
vi.mock("@/lib/insights/features", async () => {