test(rollups): force synchronous recompute before reading the aggregate

The v1.4.37.1 read-path hotfix changed `ensureUserRollupsFresh` from
an awaited populator to a fire-and-forget. On a cold testcontainer
the integration test inserts measurements and immediately reads
through `buildComprehensiveAggregate`, which now no longer waits for
the rollup-write path to land — the coverage probe sees no buckets
and the `dailyByType` branch returns an empty object.

Calls `recomputeUserRollups(user.id)` explicitly in the test setup
so the rollup-driven branch is exercised deterministically. Matches
the production warm-cache contract (the test was always asserting
the rollup-fed shape, just no longer racing against it).
This commit is contained in:
Marc-André Bombeck committed 2026-05-17 23:55:44 +02:00
1 parent 9da5b7022e
commit 61208da6ec
1 file changed
+7
@@ -419,6 +419,13 @@ describe("measurement rollups — integration", () => {
}
await prisma.measurement.createMany({ data: rows });
// v1.4.37.1 — the aggregator now fires `ensureUserRollupsFresh`
// and-forgets; on a cold testcontainer that means the rollups are
// not yet present when the aggregate reads. Force a synchronous
// recompute here so the rollup-driven `dailyByType` branch is
// exercised (matches the production warm-cache path).
await recomputeUserRollups(user.id);
const aggregate = await buildComprehensiveAggregate(user.id);
// Parallel live aggregation — same shape the legacy SQL emitted.