Files
HealthLog/src/components/insights/__tests__/chart-tooltip-observer.test.ts
T
Marc-André Bombeck 7bef199039 v1.4.33 — polish and reliability
Quality-leap release between two HealthKit milestones. The headline is a P0 hotfix for the `/api/analytics` 500 that broke the Insights mother page for any account with more than a few thousand measurements: the six per-metric status helpers were spreading the entire numeric history into `Math.min` / `Math.max`, which trips a stack overflow once a single argument list exceeds the V8 spread cap. Both the surfaced symptom and the latent risk in five sibling helpers were folded onto a reduce-based min/max path.

Around that hotfix landed a deep polish pass: the Insights mother page now defers three below-the-fold blocks behind `next/dynamic` to trim the cold mount cost, the analytics endpoint gained a `?slice=summaries` slim slice that the per-metric sub-pages now ride, the Coach snapshot builder picked up a 60 s LRU keyed on `(userId, scope)`, the Settings shell consolidated three duplicate copies of the about / notifications / about-dropdown surfaces, the navigation strip dropped a redundant "Home" group label and a colliding "Notifications" sibling, every icon-only button on the medications and admin surfaces gained an accessible name, every Progress bar gained one too, three pages had their heading hierarchy repaired to a sequential h1 → h2 → h3, the mobile Coach FAB now hides while a chart tooltip is open so it cannot occlude the read-out, and the auth shell normalised every authenticated route to a single `max-w-screen-xl` container.

Also lands the Apple App Site Association handler at `/.well-known/apple-app-site-association` on every host that fronts the app, advertising the iOS bundle's App ID prefix (S8WDX4W5KX.dev.healthlog.app) under `webcredentials.apps` so the passkey ceremony shares cleanly between the web origin and the iOS app.

The release closes nineteen issues from a five-surface audit + a runtime bug-hunt pass, plus six follow-up tracks of polish across the affected surfaces.
2026-05-16 19:46:43 +02:00

71 lines
2.3 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
__resetChartTooltipObserverForTests,
getChartTooltipActive,
getChartTooltipActiveServer,
subscribeChartTooltipActive,
} from "../chart-tooltip-observer";
/**
* v1.4.33 (F15) — chart-tooltip observer contract tests.
*
* The full DOM-side behaviour (MutationObserver watching `[class*=
* "recharts-tooltip-wrapper"]` visibility flips) lives behind a guard
* that no-ops when `document` is undefined — which is the case in the
* default vitest node environment. These tests pin the SSR-safe path
* and the subscribe/snapshot contract that `useSyncExternalStore`
* leans on.
*
* The integration with a real Recharts tooltip is exercised via the
* Playwright suite (mobile insight chart hover → FAB fades).
*/
describe("chart-tooltip-observer", () => {
beforeEach(() => {
__resetChartTooltipObserverForTests();
});
afterEach(() => {
__resetChartTooltipObserverForTests();
});
it("getChartTooltipActiveServer always returns false", () => {
// The SSR snapshot must never claim a tooltip is active on the
// server — there's no DOM to inspect, and a stale `true` would
// render the FAB invisible on the initial pass.
expect(getChartTooltipActiveServer()).toBe(false);
});
it("getChartTooltipActive returns false when no wrappers exist", () => {
expect(getChartTooltipActive()).toBe(false);
});
it("subscribeChartTooltipActive returns an unsubscribe function", () => {
const unsubscribe = subscribeChartTooltipActive(() => undefined);
expect(typeof unsubscribe).toBe("function");
unsubscribe();
});
it("no-ops cleanly on a server-side render (no document available)", () => {
// Document is undefined in the vitest node environment — the
// module's `start()` early-returns. Subscribing should still
// succeed; the listener simply never fires.
let calls = 0;
const unsubscribe = subscribeChartTooltipActive(() => {
calls += 1;
});
expect(getChartTooltipActive()).toBe(false);
expect(calls).toBe(0);
unsubscribe();
});
it("supports multiple subscribers without throwing", () => {
const a = subscribeChartTooltipActive(() => undefined);
const b = subscribeChartTooltipActive(() => undefined);
expect(getChartTooltipActive()).toBe(false);
a();
b();
});
});