From 8a26548123e51258031be84068a66c311216afbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 4 Jun 2026 17:39:39 +0200 Subject: [PATCH] test(analytics): expect the per-night sleep total in the stage-aggregation integration test The SLEEP_DURATION summary now reports one per-night asleep total (CORE + DEEP + REM) instead of a raw per-stage row count, so the stage-aggregation test expects one datapoint of 400 minutes rather than four rows. The per-stage breakdown assertions are unchanged. --- .../analytics-sleep-stages.test.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/integration/analytics-sleep-stages.test.ts b/tests/integration/analytics-sleep-stages.test.ts index 1de8d4238..64800c723 100644 --- a/tests/integration/analytics-sleep-stages.test.ts +++ b/tests/integration/analytics-sleep-stages.test.ts @@ -137,18 +137,16 @@ describe("GET /api/analytics — sleep-stage aggregation", () => { expect(response.status).toBe(200); const envelope = (await response.json()) as AnalyticsEnvelope; - // v1.4.49.1 — the analytics summaries path no longer aggregates - // stage-tagged sleep rows into a single per-night datapoint; the slim - // rollup-tier reader counts raw rows per type. The dedicated - // `sleepStages` block below still reports the night-level breakdown - // for the dashboard card; only the SLEEP_DURATION summary surfaces the - // raw per-stage count. Tracked as v1.5.1 backlog item: reintroduce - // per-day SLEEP_DURATION sum in `computeFromRollups` / - // `computeFromLiveAggregate` so the trend tile shows "1 night / 880 - // min" again rather than "4 rows / 90 min" for stage-tagged users. + // v1.11.4 — the SLEEP_DURATION summary is now computed over per-night + // asleep totals (CORE + DEEP + REM, excluding IN_BED/AWAKE), grouped by + // sleep session, rather than counting raw per-stage rows. One night of + // stage rows therefore surfaces as a single datapoint whose value is the + // night's time asleep (220 + 90 + 90 = 400 min). The dedicated + // `sleepStages` block below still reports the full per-stage breakdown + // (including IN_BED) for the dashboard card. const summary = envelope.data.summaries.SLEEP_DURATION; - expect(summary.count).toBe(4); - expect(summary.latest).toBe(90); + expect(summary.count).toBe(1); + expect(summary.latest).toBe(400); // Stage breakdown surfaces the per-stage minutes verbatim. const sleepStages = envelope.data.sleepStages;