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.
This commit is contained in:
Marc-André Bombeck committed 2026-06-04 17:39:39 +02:00
1 parent cb4fd14a8a
commit 8a26548123
1 file changed
+9 -11
@@ -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;