From 95739369e142023028ee46f14414c19e309e0f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 14 Jun 2026 21:11:05 +0200 Subject: [PATCH] fix(insights): point sleep empty-state CTA at a real settings slug --- .../sleep/__tests__/empty-state-href.test.ts | 35 +++++++++++++++++++ src/app/insights/sleep/page.tsx | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/app/insights/sleep/__tests__/empty-state-href.test.ts diff --git a/src/app/insights/sleep/__tests__/empty-state-href.test.ts b/src/app/insights/sleep/__tests__/empty-state-href.test.ts new file mode 100644 index 000000000..546cfacfe --- /dev/null +++ b/src/app/insights/sleep/__tests__/empty-state-href.test.ts @@ -0,0 +1,35 @@ +/** + * v1.17.0 — the sleep empty-state CTA must point at a REAL settings slug. + * It previously linked to `/settings/data-sources`, which is not in + * `SETTINGS_SECTION_SLUGS`, so the dynamic `[section]` route calls + * `notFound()` → a 404 dead-end. This pins the href to the `integrations` + * slug and guards against a regression to any non-existent slug. + */ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +import { describe, expect, it } from "vitest"; + +import { isSettingsSectionSlug } from "@/components/settings/section-slugs"; + +describe("sleep empty-state CTA href", () => { + it("links to /settings/integrations (a real settings slug)", () => { + const source = readFileSync( + join(process.cwd(), "src/app/insights/sleep/page.tsx"), + "utf8", + ); + const match = source.match(/href="\/settings\/([a-z-]+)"/); + expect(match, "expected a /settings/ href in the sleep page").not.toBeNull(); + const slug = match![1]; + expect(slug).toBe("integrations"); + expect(isSettingsSectionSlug(slug)).toBe(true); + }); + + it("never links to the removed /settings/data-sources slug", () => { + const source = readFileSync( + join(process.cwd(), "src/app/insights/sleep/page.tsx"), + "utf8", + ); + expect(source).not.toContain("/settings/data-sources"); + }); +}); diff --git a/src/app/insights/sleep/page.tsx b/src/app/insights/sleep/page.tsx index 514ac15a1..1cac47cd7 100644 --- a/src/app/insights/sleep/page.tsx +++ b/src/app/insights/sleep/page.tsx @@ -25,7 +25,7 @@ import { SubPageShell } from "@/components/insights/sub-page-shell"; * * v1.4.27 F17 — when `summaries.SLEEP_DURATION.count === 0` (no * Apple-Health / Withings sleep rows yet), the page short-circuits - * to an empty-state CTA pointing at `/settings/data-sources` so the + * to an empty-state CTA pointing at `/settings/integrations` so the * user can connect a sleep source. * * v1.4.28 R3d (BK-F-H1 + BK-F-M1) — analytics fetch + empty-state @@ -50,7 +50,7 @@ export default function InsightsSchlafPage() { description={t("insights.emptyState.sleep.description")} cta={