diff --git a/src/lib/query-keys/__tests__/record-write-day-keys.test.ts b/src/lib/query-keys/__tests__/record-write-day-keys.test.ts index 64f54253a..4d9133d52 100644 --- a/src/lib/query-keys/__tests__/record-write-day-keys.test.ts +++ b/src/lib/query-keys/__tests__/record-write-day-keys.test.ts @@ -11,6 +11,7 @@ import { describe, expect, it } from "vitest"; import { invalidateSymptomReads } from "@/components/symptoms/use-symptoms"; import { allergyDependentKeys, + invalidateKeys, cycleDependentKeys, documentDependentKeys, encounterDependentKeys, @@ -47,6 +48,20 @@ describe("record writes reach the day view and the timeline", () => { }, ); + it("a workout write marks the Insights presence read stale", async () => { + // The Workouts pill appears with the first workout and goes with the + // last; the presence read otherwise stays fresh for five minutes. + const client = new QueryClient(); + client.setQueryData(queryKeys.insightsPresence(), { hasWorkouts: false }); + + await invalidateKeys(client, workoutDependentKeys); + + expect( + client.getQueryState(queryKeys.insightsPresence())?.isInvalidated, + ).toBe(true); + client.clear(); + }); + it("a symptom write marks an open day and the timeline stale", async () => { const client = new QueryClient(); const day = queryKeys.day("2026-11-10"); diff --git a/src/lib/query-keys/index.ts b/src/lib/query-keys/index.ts index 57e244539..25b6195f0 100644 --- a/src/lib/query-keys/index.ts +++ b/src/lib/query-keys/index.ts @@ -364,10 +364,12 @@ export const vaccinationDependentKeys = [ * digest names a workout that just arrived and the write evicts the server's * daily caches, so the daily reads ride along; pair call sites with * `refetchInactiveDailyReads`, because both are unmounted wherever the form - * opens outside the dashboard. + * opens outside the dashboard. The Insights tab strip shows the Workouts + * pill from the presence read. */ export const workoutDependentKeys = [ queryKeys.workouts(), + queryKeys.insightsPresence(), queryKeys.dashboardSnapshot(), queryKeys.dailyDigest(), queryKeys.dayRoot(),