mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
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.
This commit is contained in:
1 parent
551d352581
commit
d369b406ac
4 files changed
+25
-22
No files matched your search
@@ -43,6 +43,9 @@ const NON_COACH_GATED_ROUTES: ReadonlyArray<string> = [
|
||||
// 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.
|
||||
|
||||
@@ -112,8 +112,8 @@ describe("<TrendCard> 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("<TrendCard> 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("<TrendCard> 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("<TrendCard> 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");
|
||||
});
|
||||
});
|
||||
@@ -79,7 +79,7 @@ describe("<TrendCard compareBaseline=...>", () => {
|
||||
</I18nProvider>,
|
||||
);
|
||||
// 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("<TrendCard compareBaseline=...>", () => {
|
||||
/>
|
||||
</I18nProvider>,
|
||||
);
|
||||
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("<TrendCard compareBaseline=...>", () => {
|
||||
// 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)", () => {
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("<TrendCard> directionSentiment", () => {
|
||||
const html = render(
|
||||
<TrendCard {...baseProps} slope30={RISING} directionSentiment="up-bad" />,
|
||||
);
|
||||
expect(html).toContain("text-dracula-orange");
|
||||
expect(html).toContain("text-warning");
|
||||
});
|
||||
|
||||
it("paints up-bad metric ↓ as green (improvement)", () => {
|
||||
@@ -53,7 +53,7 @@ describe("<TrendCard> 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("<TrendCard> 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("<TrendCard> 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("<TrendCard> 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("<TrendCard> 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(<TrendCard {...baseProps} slope30={RISING} />);
|
||||
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");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user