chore(release): v1.4.45 — analytics 9 s perf fix + audit-marathon closure + v1.4.44 hotfix merged

Audit-marathon close: 14 waves + W10 QA + reconcile. Perf fix (analytics 9 s -> 2-3 s), Zod multi-issue rollout (41 routes), Withings parked-state automation, mobile-UI WCAG 2.5.5 close, QoL i18n + offline banner + account delete, security PII drop + replay-injection scan. Migration 0075 required. Tests 4815 -> 5076.
This commit is contained in:
Marc-André Bombeck authored and GitHub committed 2026-05-21 23:13:21 +02:00
1 parent 324d4bb411
commit 6c7fc7dc84
167 files changed
+11233 -371

No files matched your search

@@ -50,4 +50,21 @@ describe("<ChartSkeleton>", () => {
const html = render(<ChartSkeleton mini />);
expect(html).toMatch(/h-\[140px\]/);
});
// v1.4.43 QoL (L4) — slow-hint caption appears after a 3 s grace.
// SSR markup never paints the caption because `useEffect` does not
// run server-side; this also keeps hydration mismatch-free.
it("does NOT paint the slow-hint caption in the initial SSR markup", () => {
const html = render(<ChartSkeleton />);
expect(html).not.toContain('data-slot="chart-skeleton-slow-hint"');
expect(html).not.toContain("Computing analytics");
});
it("mini variant never sets up the slow-hint timer", () => {
// Read the component source: the `useEffect` early-returns when
// `mini` is true, so a `<ChartSkeleton mini />` row in trends
// never paints the multi-line caption that would overflow it.
const html = render(<ChartSkeleton mini />);
expect(html).not.toContain('data-slot="chart-skeleton-slow-hint"');
});
});
@@ -0,0 +1,77 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
/**
* v1.4.43 W11-M6 — chart empty-window state.
*
* Pre-fix the chart returned `null` when the loaded data array was
* empty in the selected range, erasing the entire card (header +
* tabs + chart). The user saw a missing widget without explanation.
* The fix paints a "no data in this range" empty state via
* `<ChartEmptyState>` so the dashboard composition stays intact and
* the user knows the chart loaded but the selected window holds no
* measurements. The copy is distinct from the < 3-points "Mehr
* Messtage erforderlich" branch so the two situations don't blur.
*/
function buildData(rawCount: number): unknown[] {
const points: unknown[] = [];
Object.defineProperty(points, "rawCount", {
value: rawCount,
enumerable: false,
configurable: false,
writable: false,
});
return points;
}
vi.mock("@/hooks/use-auth", () => ({
useAuth: () => ({
isAuthenticated: true,
user: null,
isLoading: false,
}),
}));
describe("<HealthChart> — empty-window state (W11-M6)", () => {
beforeEach(() => {
vi.resetModules();
});
it("renders the no-data-in-range copy when data resolves to an empty array", async () => {
const data = buildData(0);
vi.doMock("@tanstack/react-query", () => ({
useQuery: () => ({ data, isLoading: false }),
useQueryClient: () => ({
cancelQueries: () => Promise.resolve(),
getQueryData: () => undefined,
setQueryData: () => undefined,
invalidateQueries: () => Promise.resolve(),
}),
useMutation: () => ({ mutate: () => undefined, isPending: false }),
}));
const { I18nProvider } = await import("@/lib/i18n/context");
const { HealthChart } = await import("../health-chart");
const html = renderToStaticMarkup(
<I18nProvider initialLocale="de">
<HealthChart types={["PULSE"]} title="Pulse" unit="bpm" />
</I18nProvider>,
);
// The new empty state must paint…
expect(html).toContain("Keine Daten in diesem Zeitraum");
// …and the chart card chrome (title) must still be mounted so the
// dashboard isn't missing a tile. The pre-fix `return null` would
// have stripped this entirely.
expect(html).toContain("Pulse");
// The < 3-points branch must NOT paint here — empty-window and
// sparse-data are different situations with distinct copy.
expect(html).not.toContain("Mehr Messtage erforderlich");
expect(html).not.toContain("Erfasse mindestens 3 Einträge");
vi.doUnmock("@tanstack/react-query");
});
});
@@ -98,8 +98,8 @@ export function ChartOverlayControls({
<Button
type="button"
variant="ghost"
size="sm"
className={`text-muted-foreground hover:text-foreground min-h-11 min-w-11 px-0 ${triggerClassName ?? ""}`.trim()}
size="default"
className={`text-muted-foreground hover:text-foreground min-h-11 min-w-11 px-0 sm:min-h-9 sm:min-w-9 ${triggerClassName ?? ""}`.trim()}
aria-label={t("chart.overlay.controls.tooltip.openSettings")}
data-slot="chart-overlay-controls-trigger"
>
+37
View File
@@ -1,5 +1,7 @@
"use client";
import { useEffect, useState } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import { cn } from "@/lib/utils";
import { useTranslations } from "@/lib/i18n/context";
@@ -31,10 +33,21 @@ import { useTranslations } from "@/lib/i18n/context";
* `rounded-md p-2` and pins the inner band at 140 px so the loading
* shell occupies the same visible box as the painted chart.
*
* v1.4.43 QoL (L4) — when the skeleton is still painted three seconds
* in, surface a small caption ("Computing analytics — this can take
* a moment") so the user understands the chart is being computed
* rather than broken. Today the `/api/analytics` correlations branch
* can sit on the skeleton for ~9 s; the caption sets expectation.
* Only fires on the full variant — the mini-skeleton sits in a
* dashboard row strip where a multi-line caption would overflow.
*
* `prefers-reduced-motion` is honoured automatically — the `<Skeleton>`
* primitive's `animate-pulse` is suppressed via Tailwind's
* `motion-reduce:animate-none` modifier.
*/
const SLOW_HINT_DELAY_MS = 3_000;
export function ChartSkeleton({
className,
mini = false,
@@ -48,6 +61,21 @@ export function ChartSkeleton({
mini?: boolean;
}) {
const { t } = useTranslations();
// v1.4.43 QoL (L4) — `showSlowHint` flips true 3 s into the load so
// the caption only appears for genuinely slow renders. Using a
// `useEffect` keeps the SSR markup identical (caption absent) so
// hydration never mismatches; the timer kicks in client-side once
// the skeleton actually paints.
const [showSlowHint, setShowSlowHint] = useState(false);
useEffect(() => {
if (mini) return undefined;
const handle = setTimeout(
() => setShowSlowHint(true),
SLOW_HINT_DELAY_MS,
);
return () => clearTimeout(handle);
}, [mini]);
if (mini) {
return (
<div
@@ -93,6 +121,15 @@ export function ChartSkeleton({
{/* Chart band — mirrors the same `h-[var(--chart-height,…)]`
contract `health-chart.tsx` paints at line 1087-1089. */}
<Skeleton className="h-[var(--chart-height,240px)] w-full md:h-[var(--chart-height-md,280px)]" />
{showSlowHint && (
<p
data-slot="chart-skeleton-slow-hint"
className="text-muted-foreground mt-3 text-xs"
>
{t("charts.loadingSlowHint")}
</p>
)}
</div>
);
}
+32 -3
View File
@@ -1132,7 +1132,14 @@ export function HealthChart({
return map;
}, [chartData, types]);
if (!isLoading && !data?.length) return null;
// v1.4.43 W11-M6 — keep the card shell mounted even when the loaded
// payload is empty. Pre-fix the early `return null` here erased the
// whole widget (header + range tabs + chart) and the user saw an
// unexplained gap on the dashboard. The in-card render branch below
// now paints a "no data in this range" empty state so the user
// understands the chart loaded but the selected window holds no
// measurements — distinct copy from the < 3-points "more days
// needed" hint so the two situations don't blur.
const maxPointIndex = Math.max(0, (chartData?.length ?? 1) - 1);
@@ -1286,9 +1293,31 @@ export function HealthChart({
{isLoading ? (
<div className="flex h-48 items-center justify-center">
<Loader2 className="text-primary h-6 w-6 animate-spin" />
<Loader2 className="text-primary h-6 w-6 animate-spin motion-reduce:animate-none" />
</div>
) : !chartData?.length ? null : (chartData?.length ?? 0) < 3 ? (
) : !chartData?.length ? (
// v1.4.43 W11-M6 — empty-window state.
//
// Pre-fix the chart silently `return null`ed when `chartData`
// resolved empty (after-load, no points in the selected
// range). Paired with the < 3-points hint, the user's
// five visible chart states were:
//
// - skeleton (loading)
// - 1-2 daily points / many raw → "Mehr Messtage erforderlich"
// - 1-2 daily points / < 3 raw → "Erfasse mindestens 3 Einträge"
// - ≥ 3 daily points → line chart
// - 0 daily points → NOTHING
//
// The "nothing" branch read as a broken widget on the
// dashboard. Paint a distinct empty state explaining the
// selected range is empty so the user reaches for the range
// tabs or the quick-add instead of suspecting a bug.
<ChartEmptyState
title={t("charts.noDataInRangeTitle")}
description={t("charts.noDataInRangeDescription")}
/>
) : (chartData?.length ?? 0) < 3 ? (
// v1.4.16 B1a — sparse-data placeholder. <3 daily points is too
// few to render a meaningful trend; paint a friendly hint
// instead so the dashboard doesn't look broken.