Derive the privacy page's stored-data list from the module registry

"What's stored" was six hand-kept lines that never named documents,
vaccinations, the cycle or workouts. It now names every module that
keeps records, read off the registry so a new module joins without an
edit, beside fixed lines for measurements, the profile, integration
tokens and account security, in foreground text since it is the content
of the card.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 20:46:51 +02:00
1 parent c4272343e3
commit f648168266
9 files changed
+116 -40

No files matched your search

@@ -0,0 +1,59 @@
/**
* Settings → Data & privacy: "What's stored" is read off the module registry,
* so every module that keeps records is named and a new one joins the list
* without an edit here.
*/
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";
vi.mock("@tanstack/react-query", () => ({
useQuery: () => ({ data: undefined, isLoading: true, isError: false }),
useQueryClient: () => ({ invalidateQueries: vi.fn() }),
useMutation: () => ({ mutate: vi.fn(), isPending: false }),
}));
vi.mock("@/hooks/use-auth", () => ({
useAuth: () => ({ user: null, isAuthenticated: true, isLoading: false }),
}));
vi.mock("@/components/settings/security-sessions-card", () => ({
SecuritySessionsCard: () => null,
}));
vi.mock("@/components/settings/security-activity-card", () => ({
SecurityActivityCard: () => null,
}));
vi.mock("@/components/settings/trusted-devices-card", () => ({
TrustedDevicesCard: () => null,
}));
import { I18nProvider } from "@/lib/i18n/context";
import { MODULE_KEYS, MODULE_REGISTRY } from "@/lib/modules/registry";
import { PrivacySection, storedModuleLabelKeys } from "../privacy-section";
function render(): string {
return renderToStaticMarkup(
<I18nProvider initialLocale="en">
<PrivacySection />
</I18nProvider>,
);
}
describe("Data & privacy — what's stored", () => {
it("names every module that keeps records", () => {
const keys = storedModuleLabelKeys();
for (const key of MODULE_KEYS) {
const { category, labelKey } = MODULE_REGISTRY[key];
const holdsRecords = category !== "export" && category !== "integration";
expect(keys.includes(labelKey), key).toBe(holdsRecords);
}
});
it("lists documents, vaccinations, the cycle and workouts on the page", () => {
const html = render();
const row = html.match(/data-slot="privacy-stored-modules"[^>]*>([^<]*)</);
expect(row).not.toBeNull();
for (const label of ["Documents", "Vaccinations", "Workouts"]) {
expect(row![1]).toContain(label);
}
expect(row![1]).toMatch(/Cycle/);
expect(row![1]).not.toContain("Doctor report");
});
});
+29 -5
View File
@@ -34,6 +34,7 @@ import { SecurityActivityCard } from "@/components/settings/security-activity-ca
import { TrustedDevicesCard } from "@/components/settings/trusted-devices-card";
import { useAuth } from "@/hooks/use-auth";
import { useTranslations } from "@/lib/i18n/context";
import { MODULE_KEYS, MODULE_REGISTRY } from "@/lib/modules/registry";
import { queryKeys } from "@/lib/query-keys";
import { apiGet } from "@/lib/api/api-fetch";
@@ -50,8 +51,22 @@ interface PrivacySummary {
};
}
/**
* The modules that keep records of their own, read off the module registry
* so a new module joins the "What's stored" list without anyone editing it.
* The hand-kept list this replaced had stopped at six lines while documents,
* vaccinations, the cycle and workouts were all being stored. Two categories
* hold nothing of their own: an export assembles what other modules store,
* and the connector's tokens are covered by the integration line.
*/
export function storedModuleLabelKeys(): string[] {
return MODULE_KEYS.map((key) => MODULE_REGISTRY[key])
.filter((m) => m.category !== "export" && m.category !== "integration")
.map((m) => m.labelKey);
}
export function PrivacySection() {
const { t } = useTranslations();
const { t, locale } = useTranslations();
const { isAuthenticated } = useAuth();
const {
@@ -91,11 +106,20 @@ export function PrivacySection() {
icon={Database}
title={t("settings.privacy.stored.title")}
/>
<ul className="text-muted-foreground list-disc space-y-1 text-sm">
<ul
className="list-disc space-y-1 pl-5 text-sm"
data-testid="privacy-stored-list"
>
<li>{t("settings.privacy.stored.measurements")}</li>
<li>{t("settings.privacy.stored.medications")}</li>
<li>{t("settings.privacy.stored.moodLabs")}</li>
<li>{t("settings.privacy.stored.coach")}</li>
<li>{t("settings.privacy.stored.profile")}</li>
<li data-slot="privacy-stored-modules">
{t("settings.privacy.stored.modules", {
list: new Intl.ListFormat(locale, {
style: "long",
type: "conjunction",
}).format(storedModuleLabelKeys().map((key) => t(key))),
})}
</li>
<li>{t("settings.privacy.stored.integrations")}</li>
<li>{t("settings.privacy.stored.security")}</li>
</ul>