mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
Both routes 500'd in their unit tests because the change gave them dependencies the mocks did not know about: the widgets GET reads a module flag and probes for an SDNN row, and the analytics slim slice resolves the module map. Neither test mocks `@/lib/modules/gate`, and the widgets test's prisma double has no `measurement` model — so both calls threw and the handler answered 500. Real breakage from this branch, not stale expectations. The widgets GET no longer resolves the whole module map for one answer. `hrv` is the only conditionally-dead widget and `recovery` the only module that decides it, so it reads that one flag through `isModuleEnabled`, the way this route's neighbours read a single flag. Both gate mocks spread the real module so only the one call is stubbed; everything else that imports it keeps live behaviour. The widgets `beforeEach` states the modules-on default explicitly, because `resetAllMocks` strips a factory's implementation and every test below assumes it. Added coverage for the behaviour itself rather than only unbreaking the suite: recovery off with no SDNN marks `hrv` unavailable, an account WITH SDNN keeps the toggle, and recovery on does not run the probe at all — the one added read on a hot cached route must not touch the common account.