From d369b406ac8412929550e35705adc8fa04614efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Wed, 3 Jun 2026 00:02:28 +0200 Subject: [PATCH] test(insights): align trend-sentiment + gate-inventory tests with the changes The semantic-token swap means the trend arrow/delta now emit text-success/text-warning (pixel-identical in dark, AA-safe in light), and the batched derived route joins the insightStatus allowlist alongside the single route. Update the trend-card sentiment-colour assertions and the coach-route gate inventory accordingly. --- .../coach-route-gate-inventory.test.ts | 3 +++ .../__tests__/trend-card-7d-trend.test.tsx | 12 +++++----- .../__tests__/trend-card-comparison.test.tsx | 8 +++---- .../charts/__tests__/trend-card.test.tsx | 24 +++++++++---------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/app/api/insights/__tests__/coach-route-gate-inventory.test.ts b/src/app/api/insights/__tests__/coach-route-gate-inventory.test.ts index 37ea6fd23..fbbbe4f92 100644 --- a/src/app/api/insights/__tests__/coach-route-gate-inventory.test.ts +++ b/src/app/api/insights/__tests__/coach-route-gate-inventory.test.ts @@ -43,6 +43,9 @@ const NON_COACH_GATED_ROUTES: ReadonlyArray = [ // the rollup tier; gates on the same `insightStatus` sub-flag as the // assessment routes (no Coach prose). "src/app/api/insights/derived/route.ts", + // v1.10.0 — batched derived-metric route (the dashboard fan-out fix). + // Same pure compute + `insightStatus` sub-flag as the single route. + "src/app/api/insights/derived/batch/route.ts", "src/app/api/insights/medication-compliance-status/route.ts", // v1.8.7.1 — generic per-HealthKit-metric assessment. Gated on the // same `insightStatus` sub-flag as the seven specialised status routes. diff --git a/src/components/charts/__tests__/trend-card-7d-trend.test.tsx b/src/components/charts/__tests__/trend-card-7d-trend.test.tsx index 35ff4c0b7..2622c9a9c 100644 --- a/src/components/charts/__tests__/trend-card-7d-trend.test.tsx +++ b/src/components/charts/__tests__/trend-card-7d-trend.test.tsx @@ -112,8 +112,8 @@ describe(" 7-day trend label", () => { expect(html).toContain("±0"); // Tiny absolute deltas never paint sentiment colour — they read // as "no movement" regardless of metric type. - expect(html).not.toContain("text-dracula-green"); - expect(html).not.toContain("text-dracula-orange"); + expect(html).not.toContain("text-success"); + expect(html).not.toContain("text-warning"); }); it("colors a +delta orange on an up-bad metric (weight rising = bad)", () => { @@ -129,7 +129,7 @@ describe(" 7-day trend label", () => { // HTML, so we assert orange is present in a delta-bearing render. // (Tile arrow is muted for stable slope or omitted icon — but the // delta paints regardless, so orange must appear.) - expect(html).toContain("text-dracula-orange"); + expect(html).toContain("text-warning"); }); it("colors a +delta green on an up-good metric (mood rising = good)", () => { @@ -146,7 +146,7 @@ describe(" 7-day trend label", () => { trend7Delta={0.5} />, ); - expect(html).toContain("text-dracula-green"); + expect(html).toContain("text-success"); }); it("paints neutral metrics muted regardless of delta direction", () => { @@ -159,7 +159,7 @@ describe(" 7-day trend label", () => { ); expect(html).toContain('data-slot="trend7-delta"'); expect(html).toContain("text-muted-foreground"); - expect(html).not.toContain("text-dracula-green"); - expect(html).not.toContain("text-dracula-orange"); + expect(html).not.toContain("text-success"); + expect(html).not.toContain("text-warning"); }); }); diff --git a/src/components/charts/__tests__/trend-card-comparison.test.tsx b/src/components/charts/__tests__/trend-card-comparison.test.tsx index 052af79bc..03436a920 100644 --- a/src/components/charts/__tests__/trend-card-comparison.test.tsx +++ b/src/components/charts/__tests__/trend-card-comparison.test.tsx @@ -79,7 +79,7 @@ describe("", () => { , ); // Down-trend on an up-bad metric is "improvement" → green. - expect(html).toMatch(/text-dracula-green/); + expect(html).toMatch(/text-success/); }); it("paints an up-good metric worsening (negative delta) with the orange sentiment class", () => { @@ -99,7 +99,7 @@ describe("", () => { /> , ); - expect(html).toMatch(/text-dracula-orange/); + expect(html).toMatch(/text-warning/); }); it("renders muted color when delta is exactly zero (stable)", () => { @@ -122,8 +122,8 @@ describe("", () => { // Stable + neutral both push to muted-foreground. expect(html).toMatch(/text-muted-foreground/); // Sentiment colour classes must not appear for a stable delta. - expect(html).not.toMatch(/text-dracula-green.*tile-compare-delta/); - expect(html).not.toMatch(/text-dracula-orange.*tile-compare-delta/); + expect(html).not.toMatch(/text-success.*tile-compare-delta/); + expect(html).not.toMatch(/text-warning.*tile-compare-delta/); }); it("suppresses the callout when compareDelta is null (insufficient prior-period data)", () => { diff --git a/src/components/charts/__tests__/trend-card.test.tsx b/src/components/charts/__tests__/trend-card.test.tsx index 926480a78..316055747 100644 --- a/src/components/charts/__tests__/trend-card.test.tsx +++ b/src/components/charts/__tests__/trend-card.test.tsx @@ -42,7 +42,7 @@ describe(" directionSentiment", () => { const html = render( , ); - expect(html).toContain("text-dracula-orange"); + expect(html).toContain("text-warning"); }); it("paints up-bad metric ↓ as green (improvement)", () => { @@ -53,7 +53,7 @@ describe(" directionSentiment", () => { directionSentiment="up-bad" />, ); - expect(html).toContain("text-dracula-green"); + expect(html).toContain("text-success"); }); it("paints up-good metric ↑ as green", () => { @@ -64,7 +64,7 @@ describe(" directionSentiment", () => { directionSentiment="up-good" />, ); - expect(html).toContain("text-dracula-green"); + expect(html).toContain("text-success"); }); it("paints up-good metric ↓ as orange", () => { @@ -75,7 +75,7 @@ describe(" directionSentiment", () => { directionSentiment="up-good" />, ); - expect(html).toContain("text-dracula-orange"); + expect(html).toContain("text-warning"); }); it("keeps neutral metric arrows muted regardless of direction", () => { @@ -94,11 +94,11 @@ describe(" directionSentiment", () => { />, ); expect(up).toContain("text-muted-foreground"); - expect(up).not.toContain("text-dracula-green"); - expect(up).not.toContain("text-dracula-orange"); + expect(up).not.toContain("text-success"); + expect(up).not.toContain("text-warning"); expect(down).toContain("text-muted-foreground"); - expect(down).not.toContain("text-dracula-green"); - expect(down).not.toContain("text-dracula-orange"); + expect(down).not.toContain("text-success"); + expect(down).not.toContain("text-warning"); }); it("keeps stable-trend arrows muted even when sentiment is set", () => { @@ -111,15 +111,15 @@ describe(" directionSentiment", () => { ); // Stable slope = no value judgement; the arrow points sideways. expect(html).toContain("text-muted-foreground"); - expect(html).not.toContain("text-dracula-green"); - expect(html).not.toContain("text-dracula-orange"); + expect(html).not.toContain("text-success"); + expect(html).not.toContain("text-warning"); }); it("defaults to neutral when sentiment is omitted (back-compat)", () => { const html = render(); expect(html).toContain("text-muted-foreground"); - expect(html).not.toContain("text-dracula-green"); - expect(html).not.toContain("text-dracula-orange"); + expect(html).not.toContain("text-success"); + expect(html).not.toContain("text-warning"); }); });