From f2b146556a04a6e574a26d0f4888d6a4509b2c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 19 Jul 2026 05:13:29 +0200 Subject: [PATCH] test(insights): cover the full window with resting rows in the workout-PULSE case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fixture described a clean resting series but supplied rows for only twenty of the thirty days it fed PULSE for. Now that the resolver merges per day, the ten resting-free days are estimated from their own readings — and on a day whose only readings are a 150 bpm workout the honest estimate falls outside the band. Match the spans so the case tests what its name claims; gap-day behaviour is pinned in resting-pulse.test.ts. --- src/lib/insights/__tests__/pulse-status.test.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/insights/__tests__/pulse-status.test.ts b/src/lib/insights/__tests__/pulse-status.test.ts index e267d9fd2..1aed06d5c 100644 --- a/src/lib/insights/__tests__/pulse-status.test.ts +++ b/src/lib/insights/__tests__/pulse-status.test.ts @@ -124,9 +124,18 @@ describe("generatePulseStatusForUser — A2 resting-target in-target %", () => { measuredAt: new Date(now.getTime() - (i % 30) * dayMs), }); } - // Clean resting series, comfortably inside a 60-100 band. + // Clean resting series, comfortably inside a 60-100 band, covering the + // SAME 30-day span as the PULSE above. The span has to match for the + // fixture to mean what the test name claims: the resolver merges per + // day, so a day with no resting row of its own is estimated from that + // day's PULSE rather than dropped. Leaving ten of the thirty days + // resting-free made this assert the merge's gap-fill behaviour by + // accident — on days whose only readings are a 150 bpm workout, the + // honest estimate IS out of band. Gap-day behaviour is pinned directly + // in `resting-pulse.test.ts`; this case is about preferring the clean + // signal over workout HR where both exist. const restingRecords: Array<{ value: number; measuredAt: Date }> = []; - for (let d = 0; d < 20; d++) { + for (let d = 0; d < 30; d++) { restingRecords.push({ value: 72, measuredAt: new Date(now.getTime() - d * dayMs),