diff --git a/src/components/insights/__tests__/healthkit-metric-page-hrv-measures.test.tsx b/src/components/insights/__tests__/healthkit-metric-page-hrv-measures.test.tsx index 3064ffb45..455a59224 100644 --- a/src/components/insights/__tests__/healthkit-metric-page-hrv-measures.test.tsx +++ b/src/components/insights/__tests__/healthkit-metric-page-hrv-measures.test.tsx @@ -22,11 +22,16 @@ vi.mock("@/hooks/use-ai-capability", () => ({ })); vi.mock("next/dynamic", () => ({ default: () => { - const Stub = (props: { types?: string[]; title?: string }) => ( + const Stub = (props: { + types?: string[]; + title?: string; + onVisibleStats?: unknown; + }) => (
); Stub.displayName = "HealthChartStub"; @@ -92,6 +97,24 @@ describe("/insights/hrv — SDNN and RMSSD kept apart (#1110)", () => { expect(found[1]!.title).toMatch(/RMSSD$/); }); + it("lets only the primary chart write the stat strip's window", () => { + // Two charts writing the one stats slot replaced each other's window on + // every render: React's update-depth error, and the chart failed to load. + analyticsMock.mockReturnValue({ + data: { + summaries: { + HEART_RATE_VARIABILITY: { count: 30 }, + HRV_RMSSD: { count: 28 }, + }, + }, + isEmpty: false, + }); + const flags = [...render().matchAll(/data-reports-stats="(yes|no)"/g)].map( + (m) => m[1], + ); + expect(flags).toEqual(["yes", "no"]); + }); + it("keeps one unlabelled SDNN chart when there is no RMSSD", () => { analyticsMock.mockReturnValue({ data: { summaries: { HEART_RATE_VARIABILITY: { count: 30 } } }, diff --git a/src/components/insights/healthkit-metric-page.tsx b/src/components/insights/healthkit-metric-page.tsx index 5acc7c3bb..3863e9062 100644 --- a/src/components/insights/healthkit-metric-page.tsx +++ b/src/components/insights/healthkit-metric-page.tsx @@ -509,7 +509,9 @@ export function HealthKitMetricPage({ userTimezone={user?.timezone} valueScale={resolvedScale} valueOffset={resolvedOffset} - onVisibleStats={onVisibleStats} + // No `onVisibleStats`: the strip describes the primary measure, and + // two charts writing the one stats slot would replace each other's + // window on every render without end. showDataTable /> ) : null} diff --git a/src/components/settings/integrations/metric-freshness-disclosure.tsx b/src/components/settings/integrations/metric-freshness-disclosure.tsx index ae9fba69a..54a23864e 100644 --- a/src/components/settings/integrations/metric-freshness-disclosure.tsx +++ b/src/components/settings/integrations/metric-freshness-disclosure.tsx @@ -129,7 +129,7 @@ export function MetricFreshnessDisclosure< {open && ( -