mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean baseline. Formatting only — no behaviour change. Generator-owned and vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
1 parent
b3fea2ef59
commit
1f4ba5939d
1000 files changed
+12130
-8385
No files matched your search
@@ -48,14 +48,25 @@ const ALL_AVAILABLE = operator();
|
||||
|
||||
describe("resolveModuleEnabled — disabled allowlist (default-on)", () => {
|
||||
it("enables a module when no preference is recorded", () => {
|
||||
expect(resolveModuleEnabled("mood", inputs(), true, ALL_AVAILABLE)).toBe(true);
|
||||
expect(resolveModuleEnabled("sleep", inputs(), true, ALL_AVAILABLE)).toBe(true);
|
||||
expect(resolveModuleEnabled("labs", inputs(), true, ALL_AVAILABLE)).toBe(true);
|
||||
expect(resolveModuleEnabled("mood", inputs(), true, ALL_AVAILABLE)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(resolveModuleEnabled("sleep", inputs(), true, ALL_AVAILABLE)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(resolveModuleEnabled("labs", inputs(), true, ALL_AVAILABLE)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("enables a module when the key is present and true", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("mood", inputs({ modulePreferences: { mood: true } }), true, ALL_AVAILABLE),
|
||||
resolveModuleEnabled(
|
||||
"mood",
|
||||
inputs({ modulePreferences: { mood: true } }),
|
||||
true,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
@@ -72,7 +83,9 @@ describe("resolveModuleEnabled — disabled allowlist (default-on)", () => {
|
||||
|
||||
it("isolates per-module: disabling one leaves siblings on", () => {
|
||||
const i = inputs({ modulePreferences: { workouts: false } });
|
||||
expect(resolveModuleEnabled("workouts", i, true, ALL_AVAILABLE)).toBe(false);
|
||||
expect(resolveModuleEnabled("workouts", i, true, ALL_AVAILABLE)).toBe(
|
||||
false,
|
||||
);
|
||||
expect(resolveModuleEnabled("recovery", i, true, ALL_AVAILABLE)).toBe(true);
|
||||
expect(resolveModuleEnabled("labs", i, true, ALL_AVAILABLE)).toBe(true);
|
||||
});
|
||||
@@ -159,7 +172,12 @@ describe("resolveModuleEnabled — cycle delegation", () => {
|
||||
|
||||
it("a MALE account with a null toggle is cycle-disabled", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("cycle", inputs({ gender: "MALE" }), true, ALL_AVAILABLE),
|
||||
resolveModuleEnabled(
|
||||
"cycle",
|
||||
inputs({ gender: "MALE" }),
|
||||
true,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -167,33 +185,53 @@ describe("resolveModuleEnabled — cycle delegation", () => {
|
||||
describe("resolveModuleEnabled — coach delegation (two-layer)", () => {
|
||||
it("is enabled only when the operator master flag AND !disableCoach", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("coach", inputs({ disableCoach: false }), true, ALL_AVAILABLE),
|
||||
resolveModuleEnabled(
|
||||
"coach",
|
||||
inputs({ disableCoach: false }),
|
||||
true,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("is disabled when the per-user opt-out is set", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("coach", inputs({ disableCoach: true }), true, ALL_AVAILABLE),
|
||||
resolveModuleEnabled(
|
||||
"coach",
|
||||
inputs({ disableCoach: true }),
|
||||
true,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("is disabled when the operator master flag is off", () => {
|
||||
expect(
|
||||
resolveModuleEnabled("coach", inputs({ disableCoach: false }), false, ALL_AVAILABLE),
|
||||
resolveModuleEnabled(
|
||||
"coach",
|
||||
inputs({ disableCoach: false }),
|
||||
false,
|
||||
ALL_AVAILABLE,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("ignores the module blob for coach", () => {
|
||||
// A crafted `{ coach: true }` cannot re-enable against a disabled
|
||||
// operator flag or a user opt-out.
|
||||
const i = inputs({ disableCoach: true, modulePreferences: { coach: true } });
|
||||
const i = inputs({
|
||||
disableCoach: true,
|
||||
modulePreferences: { coach: true },
|
||||
});
|
||||
expect(resolveModuleEnabled("coach", i, true, ALL_AVAILABLE)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("insights — narrative layer, not a delegated module", () => {
|
||||
it("resolves from the disabled allowlist like the other secondary domains", () => {
|
||||
expect(resolveModuleEnabled("insights", inputs(), true, ALL_AVAILABLE)).toBe(true);
|
||||
expect(
|
||||
resolveModuleEnabled("insights", inputs(), true, ALL_AVAILABLE),
|
||||
).toBe(true);
|
||||
expect(
|
||||
resolveModuleEnabled(
|
||||
"insights",
|
||||
|
||||
@@ -104,7 +104,11 @@ export function mergeAvailabilityPatch(
|
||||
// Start from the existing persisted blob, keeping only known boolean
|
||||
// entries, then overlay the validated patch.
|
||||
const merged: Record<string, boolean> = {};
|
||||
if (existing != null && typeof existing === "object" && !Array.isArray(existing)) {
|
||||
if (
|
||||
existing != null &&
|
||||
typeof existing === "object" &&
|
||||
!Array.isArray(existing)
|
||||
) {
|
||||
for (const [k, v] of Object.entries(existing as Record<string, unknown>)) {
|
||||
if (isModuleKey(k) && typeof v === "boolean") {
|
||||
merged[k] = v;
|
||||
|
||||
@@ -115,11 +115,7 @@ export type ModuleKey = (typeof MODULE_KEYS)[number];
|
||||
* `ModuleKey`, so the gate never reads it and the PATCH validator rejects
|
||||
* it. (Medications is a toggleable module since D3 — see `MODULE_KEYS`.)
|
||||
*/
|
||||
export const CORE_DOMAIN_KEYS = [
|
||||
"weight",
|
||||
"bloodPressure",
|
||||
"pulse",
|
||||
] as const;
|
||||
export const CORE_DOMAIN_KEYS = ["weight", "bloodPressure", "pulse"] as const;
|
||||
|
||||
export type CoreDomainKey = (typeof CORE_DOMAIN_KEYS)[number];
|
||||
|
||||
@@ -250,6 +246,8 @@ export function isModuleKey(key: string): key is ModuleKey {
|
||||
}
|
||||
|
||||
/** The two delegated keys, resolved by their existing source of truth. */
|
||||
export function moduleDelegatesTo(key: ModuleKey): ModuleDelegation | undefined {
|
||||
export function moduleDelegatesTo(
|
||||
key: ModuleKey,
|
||||
): ModuleDelegation | undefined {
|
||||
return MODULE_REGISTRY[key].delegatesTo;
|
||||
}
|
||||
Reference in new issue
Block a user