diff --git a/src/components/dashboard/hero/__tests__/briefing-spotlight.test.tsx b/src/components/dashboard/hero/__tests__/briefing-spotlight.test.tsx index 2d6a6eb34..ed04df2dd 100644 --- a/src/components/dashboard/hero/__tests__/briefing-spotlight.test.tsx +++ b/src/components/dashboard/hero/__tests__/briefing-spotlight.test.tsx @@ -180,4 +180,34 @@ describe("", () => { const rows = html.match(/data-slot="dashboard-briefing-spotlight-row"/g); expect(rows).toHaveLength(3); }); + + it("stacks headline over delta below sm and keeps the row at sm+", () => { + const html = render({ + briefing: briefing({ + signalsOfDay: [ + { + sourceMetric: "bp", + tone: "watch", + headline: + "Systolischer Blutdruck deutlich unter deinem Monatsmittel gemessen", + nudge: "n", + delta: "−12 mmHg vs. 30-Tage-Mittel", + }, + ], + }), + briefingState: "ready", + briefingStale: false, + }); + // Phone-first column, row restored at sm+ — a wide delta must never + // squeeze the headline into a narrow multi-line column (or push + // itself past the tile edge). + expect(html).toMatch( + /class="[^"]*flex min-w-0 flex-1 flex-col gap-1 sm:flex-row[^"]*"/, + ); + // The delta is left-aligned content-width in the stacked state and + // only refuses to shrink in the sm+ row. + expect(html).toMatch( + /data-slot="dashboard-briefing-spotlight-delta"[^>]*class="[^"]*self-start[^"]*sm:shrink-0[^"]*"/, + ); + }); }); diff --git a/src/components/dashboard/hero/briefing-spotlight.tsx b/src/components/dashboard/hero/briefing-spotlight.tsx index 5954030a8..f18dfa928 100644 --- a/src/components/dashboard/hero/briefing-spotlight.tsx +++ b/src/components/dashboard/hero/briefing-spotlight.tsx @@ -196,7 +196,14 @@ export function BriefingSpotlight({ )} aria-hidden="true" /> -
+ {/* Phone widths stack headline over delta — a long + signal headline beside a long delta squeezed the + headline into a one-word-per-line column and pushed + the delta past the tile edge. At `sm+` the + side-by-side row returns. The headline always wraps + (content is never truncated); only the delta is meta + and may stay on one line. */} +

{stripChartTokens(row.headline)}

@@ -204,7 +211,7 @@ export function BriefingSpotlight({ diff --git a/src/components/insights/__tests__/daily-briefing.test.tsx b/src/components/insights/__tests__/daily-briefing.test.tsx index 3bd9bdb85..8db6630e4 100644 --- a/src/components/insights/__tests__/daily-briefing.test.tsx +++ b/src/components/insights/__tests__/daily-briefing.test.tsx @@ -102,6 +102,20 @@ describe("", () => { expect(html).toContain("+6 mmHg"); }); + it("stacks headline over delta below sm and keeps the row at sm+", () => { + const html = render(); + // Phone-first column (headline above, delta beneath), side-by-side + // restored at sm+ — a wide delta must never squeeze the headline + // into a narrow multi-line column. + expect(html).toMatch( + /class="flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between sm:gap-3"/, + ); + // Delta badge stays content-width + left-aligned in the stacked state. + expect(html).toMatch( + /data-slot="daily-briefing-delta"[^>]*class="[^"]*self-start[^"]*sm:shrink-0[^"]*"/, + ); + }); + it("does NOT render a delta badge when delta is null", () => { const html = render( @@ -243,7 +245,11 @@ function BriefingRow({ aria-hidden="true" />
-
+ {/* Phone widths stack headline over delta (same treatment as the + dashboard spotlight rows): side-by-side squeezed a long + headline into a narrow multi-line column beside a long delta. + At `sm+` the row layout returns. */} +

{stripChartTokens(headline)}