Files
HealthLog/src/components/settings/__tests__/section-frame-harness.tsx
T
Marc-André Bombeck d2ff7cb769 Settle the suite-wide fallout of the wave
- The record-settings contract, slug-list, and section-frame tests
  follow the slugs that left the registry (layout children resolve
  their headings from the layout namespace, like production).
- The orphaned settings.sections.<module>.title/description keys leave
  all six locales; the reverse-coverage guard flagged them the moment
  their nav entries stopped existing.
- The operator-cap ledger read fails open on a read error — the
  reservation layer still meters against the same ledger, and a
  transient blip must not take the fallback chain down.
- The reaper queue joins the subsystem surface; its healed count and
  the sweep's nag_dismissed join the job-fact vocabulary.
- The intake-event contract fixture carries the full row the resource
  now declares; the workouts empty-state test asserts the
  source-neutral cue; the persister poll gates on rendered content
  first.
2026-08-14 06:37:30 +02:00

70 lines
2.2 KiB
TypeScript

"use client";
/**
* Test-only harness that reproduces the page heading the live `SettingsShell`
* paints for a given section slug (`settings-shell.tsx` headingBlock). The
* per-section SSR smoke tests render a section body through this harness so
* they can assert the visible heading + its historic `settings-section-<slug>-title`
* id alongside the body — mirroring what a user sees on the route.
*
* Production no longer wraps section bodies in a standalone frame component:
* the shell paints the heading from the slug and each section body is just its
* cards. This harness lives in `__tests__` only and is never bundled.
*/
import * as React from "react";
import { useTranslations } from "@/lib/i18n/context";
/**
* v1.37.19 — the layout-hub children left `SETTINGS_SECTION_SLUGS`; their
* live headings resolve from `settings.sections.layout.<module>.*` (the
* layout-groups registry), so the harness mirrors that mapping.
*/
const LAYOUT_CHILD_SLUGS = new Set([
"dashboard",
"insights",
"medications",
"mood",
"labs",
"illness",
"vorsorge",
]);
export function SettingsSectionFrame({
slug,
children,
}: {
/**
* A section slug OR a layout-hub child id (`dashboard`, `mood`, …) — the
* children left `SETTINGS_SECTION_SLUGS` in v1.37.19 but their heading
* keys and section bodies live on under `/settings/layout/<module>`.
*/
slug: string;
children: React.ReactNode;
}) {
const { t } = useTranslations();
const titleId = `settings-section-${slug}-title`;
const isLayoutChild = LAYOUT_CHILD_SLUGS.has(slug);
const titleKey = isLayoutChild
? `settings.sections.layout.${slug}.title`
: `settings.sections.${slug}.title`;
const subtitleKey = isLayoutChild
? `settings.sections.layout.${slug}.description`
: `settings.sections.${slug}.subtitle`;
return (
<section aria-labelledby={titleId} className="space-y-6">
<div className="flex items-start justify-between gap-2">
<div className="min-w-0">
<h1 id={titleId} className="text-2xl font-bold tracking-tight">
{t(titleKey)}
</h1>
<p className="text-muted-foreground text-sm">{t(subtitleKey)}</p>
</div>
</div>
{children}
</section>
);
}