mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
chore(targets): deprecate the targets page and drop it from the menu
Target editing now lives inline on the insights pages, so the standalone targets page is no longer a navigation destination. Remove its sidebar and bottom-nav (overflow) entries and add a top deprecation banner that points the user at the insights pages and notes the page will be removed in a future release. The page stays routable: the /zielwerte to /targets redirect remains and the route still renders. Removal later is UI-only because the insights panel consumes the same targets read and threshold-override write. New deprecation strings land across all six locales.
This commit is contained in:
1 parent
c72715bb62
commit
cd1eaa1a4e
13 files changed
+185
-12
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
|
||||
/**
|
||||
* v1.8.6 — `/targets` deprecation banner.
|
||||
*
|
||||
* The Targets (Zielwerte) page is deprecated: target-range editing moved
|
||||
* inline into the Insights category pages. The page stays routable but
|
||||
* carries a top banner telling the user where editing lives now and that
|
||||
* the page will be removed in a future release. This SSR test pins the
|
||||
* banner copy + structure.
|
||||
*
|
||||
* The page leans on `useAuth`, two `useQuery` reads, `useFeatureFlags`
|
||||
* and `useCoachHandoff`; all are stubbed so the render reaches the
|
||||
* banner without standing up an App-Router runtime or a QueryClient.
|
||||
*/
|
||||
|
||||
vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({
|
||||
isAuthenticated: true,
|
||||
user: { id: "u1", disableCoach: false },
|
||||
}),
|
||||
}));
|
||||
|
||||
// The page issues two `useQuery` reads (targets payload + provider
|
||||
// chain). Drive both off the same stub: the first call resolves the
|
||||
// targets payload, the rest return a null provider chain.
|
||||
let queryCall = 0;
|
||||
const TARGETS_PAYLOAD = {
|
||||
targets: [],
|
||||
bpDiastolic: { current: null, average30: null, range: null },
|
||||
profile: { heightCm: 175, age: 40, gender: "male", glucoseUnit: "mg/dL" },
|
||||
};
|
||||
vi.mock("@tanstack/react-query", () => ({
|
||||
useQuery: () => {
|
||||
queryCall += 1;
|
||||
if (queryCall === 1) {
|
||||
return { data: TARGETS_PAYLOAD, isLoading: false };
|
||||
}
|
||||
return { data: null, isLoading: false };
|
||||
},
|
||||
}));
|
||||
|
||||
// Turn Coach off so the page never mounts the SSE drawer machinery.
|
||||
vi.mock("@/hooks/use-feature-flags", () => ({
|
||||
useFeatureFlags: () => ({
|
||||
enabled: false,
|
||||
coach: false,
|
||||
briefing: false,
|
||||
insightStatus: false,
|
||||
correlations: false,
|
||||
healthScoreExplainer: false,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("@/hooks/use-coach-handoff", () => ({
|
||||
useCoachHandoff: () => ({
|
||||
coachOpen: false,
|
||||
setCoachOpen: vi.fn(),
|
||||
coachPrefill: null,
|
||||
coachScope: null,
|
||||
askCoach: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const { default: TargetsPage } = await import("../page");
|
||||
|
||||
function render(locale: "en" | "de" = "en") {
|
||||
queryCall = 0;
|
||||
return renderToStaticMarkup(
|
||||
<I18nProvider initialLocale={locale}>
|
||||
<TargetsPage />
|
||||
</I18nProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("<TargetsPage> deprecation banner", () => {
|
||||
it("renders the deprecation banner with title + body", () => {
|
||||
const html = render();
|
||||
expect(html).toContain('data-slot="targets-deprecation"');
|
||||
expect(html).toContain("This page is being retired");
|
||||
expect(html).toContain("Insights");
|
||||
// Reuses the warning-card visual pattern.
|
||||
expect(html).toContain("border-warning");
|
||||
});
|
||||
|
||||
it("localises the banner copy", () => {
|
||||
const html = render("de");
|
||||
expect(html).toContain("Diese Seite wird eingestellt");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,21 @@
|
||||
"use client";
|
||||
|
||||
// DEPRECATED since v1.8.6. Target-range editing moved inline into the
|
||||
// Insights category pages (the per-metric reference panel now mounts the
|
||||
// same <TargetEditSheet>), so this standalone page no longer appears in
|
||||
// the navigation. It stays routable behind the `/zielwerte`→`/targets`
|
||||
// proxy redirect and is a remove candidate after ~10 releases.
|
||||
//
|
||||
// What stays in place because Insights consumes the same API:
|
||||
// • GET /api/insights/targets — the read powering this page is the
|
||||
// same payload the Insights panel reads (`queryKeys.insightsTargets()`).
|
||||
// • PUT/DELETE /api/user/thresholds — the threshold override write the
|
||||
// inline <TargetEditSheet> calls.
|
||||
// • src/components/targets/* — TargetCard, TargetEditSheet, RangeBar,
|
||||
// ConsistencyStrip, TargetStatusPill, source-link helper are all
|
||||
// reused by the inline Insights panel.
|
||||
// Removing the page later is a UI-only change; no data or API moves.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { AlertCircle, Loader2 } from "lucide-react";
|
||||
@@ -200,6 +216,23 @@ export default function TargetsPage() {
|
||||
<p className="mt-2 text-sm">{t("targets.introText")}</p>
|
||||
</div>
|
||||
|
||||
{/* v1.8.6 — deprecation banner. Target editing moved inline into
|
||||
the Insights category pages; this page stays reachable but will
|
||||
be removed in a future release. */}
|
||||
<Card className="border-warning border-l-4" data-slot="targets-deprecation">
|
||||
<CardContent className="flex gap-3 py-3">
|
||||
<AlertCircle className="text-warning mt-0.5 h-4 w-4 shrink-0" />
|
||||
<div>
|
||||
<p className="text-sm font-medium">
|
||||
{t("targets.deprecation.title")}
|
||||
</p>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t("targets.deprecation.body")}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Profile incomplete hint */}
|
||||
{profileIncomplete && (
|
||||
<Card className="border-warning border-l-4">
|
||||
|
||||
Reference in new issue
Block a user