mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
fix: complete managed record settings
- Expose canonical defaults and reject invalid settings families\n- Localize Guardian controls and refresh dependent caches
This commit is contained in:
1 parent
e788675b82
commit
247ac8494c
16 files changed
+759
-91
No files matched your search
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { MANAGED_RECORD_SETTINGS_MODULE_DEFAULTS } from "@/lib/record-settings";
|
||||
import { ALL_METRICS } from "@/lib/validations/thresholds";
|
||||
|
||||
import { ManagedRecordSettingsForm } from "../managed-record-settings-section";
|
||||
|
||||
const render = (
|
||||
@@ -8,13 +12,15 @@ const render = (
|
||||
settings: Record<string, unknown>,
|
||||
) =>
|
||||
renderToStaticMarkup(
|
||||
<ManagedRecordSettingsForm
|
||||
disabled={false}
|
||||
family={family}
|
||||
onSave={vi.fn()}
|
||||
saveLabel="Save"
|
||||
settings={settings}
|
||||
/>,
|
||||
<I18nProvider initialLocale="en">
|
||||
<ManagedRecordSettingsForm
|
||||
disabled={false}
|
||||
family={family}
|
||||
onSave={vi.fn()}
|
||||
saveLabel="Save"
|
||||
settings={settings}
|
||||
/>
|
||||
</I18nProvider>,
|
||||
);
|
||||
|
||||
describe("managed record settings forms", () => {
|
||||
@@ -62,4 +68,26 @@ describe("managed record settings forms", () => {
|
||||
expect(html).not.toContain("<textarea");
|
||||
},
|
||||
);
|
||||
|
||||
it("renders every direct module and threshold metric for a fresh record", () => {
|
||||
const modules = render("modules", { modulePreferences: {} });
|
||||
const thresholds = render("thresholds", {
|
||||
overrides: {},
|
||||
effective: Object.fromEntries(
|
||||
ALL_METRICS.map((metric) => [
|
||||
metric,
|
||||
{ range: { greenMin: 10, greenMax: 20 } },
|
||||
]),
|
||||
),
|
||||
});
|
||||
|
||||
for (const module of Object.keys(MANAGED_RECORD_SETTINGS_MODULE_DEFAULTS)) {
|
||||
expect(modules).toContain(`name="${module}"`);
|
||||
}
|
||||
for (const metric of ALL_METRICS) {
|
||||
expect(thresholds).toContain(`value="${metric}"`);
|
||||
}
|
||||
expect(thresholds).toContain('value="10"');
|
||||
expect(thresholds).toContain('value="20"');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user