From 8b5199ee008f76f9a5e2082095286043f36f0ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 9 Oct 2026 00:41:56 +0200 Subject: [PATCH] test(e2e): tag the just-in sleep batches as a foreground sync A batch without a trigger only marks the dashboard snapshot stale since v1.42, so a snapshot an earlier spec left for the account painted the day final before this journey's own night counted. Foreground evicts. --- e2e/today-just-in.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e/today-just-in.spec.ts b/e2e/today-just-in.spec.ts index 2583b460d..6c8853330 100644 --- a/e2e/today-just-in.spec.ts +++ b/e2e/today-just-in.spec.ts @@ -162,8 +162,17 @@ test("a fresh arrival flips the day in place", async ({ page }) => { // swept by the same `e2e-just-in-` purge on the next run. const priorNight = new Date(Date.now() - 3 * 24 * 60 * 60_000); const priorWoke = new Date(priorNight.getTime() + 7 * 60 * 60_000); + // + // Tagged `foreground`, the trigger an open app sends. Since v1.42 a batch + // without it only marks the dashboard snapshot stale, and `cachedSwr` + // serves the stale cell once while it rebuilds: a snapshot an earlier + // spec left for this account (no sleep at all, so no sleep expected) + // would then paint the BEFORE state as `final`, depending on which spec + // happened to run first in the shard. `foreground` evicts, so the first + // read below is built from the rows this spec just wrote. const priorBatch = await page.request.post("/api/measurements/batch", { data: { + syncTrigger: "foreground", entries: [ { hkIdentifier: "HKCategoryTypeIdentifierSleepAnalysis", @@ -229,8 +238,11 @@ test("a fresh arrival flips the day in place", async ({ page }) => { const wokeAt = new Date(now.getTime() - 60 * 60_000); const fellAsleepAt = new Date(wokeAt.getTime() - 7 * 60 * 60_000); + // `foreground` for the same reason as the prior night above: the page + // is open while it lands. const batch = await page.request.post("/api/measurements/batch", { data: { + syncTrigger: "foreground", entries: [ { hkIdentifier: "HKCategoryTypeIdentifierSleepAnalysis",