mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
Document vault: card list drops a stray glyph and gives the real filename its own line (was truncating on the meta row); the detail sheet's close button aligns correctly — ResponsiveSheet reserved the right gutter for a close button it wasn't rendering, now conditional on showCloseButton. The open-in-coach action reads 'Coach fragen'. Bulk share: a multi-selection in the overview shares several documents in ONE link (documents-only privacy preserved, owner-scoped, up to 50 per link; >50 refuses with a toast rather than silently truncating). Reminders can link to WAIST_CIRCUMFERENCE (additive MeasurementReminderType enum value, OpenAPI regenerated). The WHO-5 and SCI well-being reminder labels were absent in all six locales and rendered their raw dotted keys (the shared 'measurementReminders.types' prefix is what showed as the stray 'Measurement Reminders Types'); added in every language. A new type-labels-i18n test asserts every dynamic reminder-type key resolves non-empty in all six bundles — the static coverage guard cannot see the dynamic key that let this through.
121 lines
3.7 KiB
TypeScript
121 lines
3.7 KiB
TypeScript
/**
|
|
* v1.18.1 (V3) — the Vorsorge measurement-type allow-list. Widened from
|
|
* the original 7 to the ~15 active-measurement set (vitals + the
|
|
* body-composition family). App-layer only — the DB column is the full
|
|
* MeasurementType enum, so this is the gate, not a migration.
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
measurementReminderTypeEnum,
|
|
createMeasurementReminderSchema,
|
|
} from "../measurement-reminders";
|
|
|
|
describe("measurementReminderTypeEnum (V3 — completeness)", () => {
|
|
const allowed = measurementReminderTypeEnum.options;
|
|
|
|
it("exposes the full active set: vitals + body composition + screenings", () => {
|
|
expect(new Set(allowed)).toEqual(
|
|
new Set([
|
|
// Vitals
|
|
"WEIGHT",
|
|
"BLOOD_PRESSURE_SYS",
|
|
"PULSE",
|
|
"BLOOD_GLUCOSE",
|
|
"OXYGEN_SATURATION",
|
|
"BODY_TEMPERATURE",
|
|
// Body composition
|
|
"BODY_FAT",
|
|
"FAT_MASS",
|
|
"FAT_FREE_MASS",
|
|
"MUSCLE_MASS",
|
|
"LEAN_BODY_MASS",
|
|
"BONE_MASS",
|
|
"TOTAL_BODY_WATER",
|
|
"VISCERAL_FAT",
|
|
"BODY_MASS_INDEX",
|
|
"WAIST_CIRCUMFERENCE",
|
|
// v1.27.6 — plannable mental-wellbeing screenings
|
|
"PHQ9_SCORE",
|
|
"GAD7_SCORE",
|
|
// v1.27.9 — WHO-5 + SCI join on the identical contract
|
|
"WHO5_SCORE",
|
|
"SCI_SCORE",
|
|
]),
|
|
);
|
|
});
|
|
|
|
it("accepts the WHO-5 / SCI screenings with the 4-week default cadence", () => {
|
|
for (const measurementType of ["WHO5_SCORE", "SCI_SCORE"]) {
|
|
const parsed = createMeasurementReminderSchema.safeParse({
|
|
label: "Screening check-in",
|
|
measurementType,
|
|
intervalDays: 28,
|
|
});
|
|
expect(parsed.success, `expected ${measurementType} to be allowed`).toBe(
|
|
true,
|
|
);
|
|
}
|
|
});
|
|
|
|
it("accepts a plannable screening reminder with the 4-week default cadence", () => {
|
|
const parsed = createMeasurementReminderSchema.safeParse({
|
|
label: "PHQ-9 Check-in",
|
|
measurementType: "PHQ9_SCORE",
|
|
intervalDays: 28,
|
|
});
|
|
expect(parsed.success).toBe(true);
|
|
});
|
|
|
|
it("accepts a newly-added body-composition type on create", () => {
|
|
const parsed = createMeasurementReminderSchema.safeParse({
|
|
label: "Körperzusammensetzung messen",
|
|
measurementType: "MUSCLE_MASS",
|
|
intervalDays: 7,
|
|
});
|
|
expect(parsed.success).toBe(true);
|
|
});
|
|
|
|
it("accepts WAIST_CIRCUMFERENCE (the added body-composition target)", () => {
|
|
expect(allowed).toContain("WAIST_CIRCUMFERENCE");
|
|
const parsed = createMeasurementReminderSchema.safeParse({
|
|
label: "Taillenumfang messen",
|
|
measurementType: "WAIST_CIRCUMFERENCE",
|
|
intervalDays: 30,
|
|
});
|
|
expect(parsed.success).toBe(true);
|
|
});
|
|
|
|
it("does NOT add WAIST_TO_HEIGHT (only waist circumference was requested)", () => {
|
|
expect(allowed).not.toContain("WAIST_TO_HEIGHT");
|
|
});
|
|
|
|
it("matches BP on the SYS sentinel only (DIA would double-count)", () => {
|
|
expect(allowed).toContain("BLOOD_PRESSURE_SYS");
|
|
expect(allowed).not.toContain("BLOOD_PRESSURE_DIA");
|
|
});
|
|
|
|
it("deliberately excludes passive / cumulative / event types", () => {
|
|
for (const excluded of [
|
|
"RESTING_HEART_RATE",
|
|
"HEART_RATE_VARIABILITY",
|
|
"VO2_MAX",
|
|
"ACTIVITY_STEPS",
|
|
"RECOVERY_SCORE",
|
|
"SLEEP_DURATION",
|
|
"IRREGULAR_RHYTHM_NOTIFICATION",
|
|
]) {
|
|
expect(allowed).not.toContain(excluded);
|
|
}
|
|
});
|
|
|
|
it("still accepts a free-text reminder (null type) resolving on satisfy / lab", () => {
|
|
const parsed = createMeasurementReminderSchema.safeParse({
|
|
label: "Großes Blutbild",
|
|
measurementType: null,
|
|
rrule: "FREQ=YEARLY",
|
|
});
|
|
expect(parsed.success).toBe(true);
|
|
});
|
|
});
|