Give the just-in spec a record that expects sleep

The scenario purges every sleep row so last night can be the arrival that
flips the day. That left an account with no sleep source at all, which now
reads `final` on purpose, so the provisional assertion could not be reached.

Seeding a night from three days ago restores what the scenario means: a
record that does track sleep, waiting for last night's. Written through the
same ingest route as the fresh night and swept by the same purge.
This commit is contained in:
Marc-André Bombeck committed 2026-08-16 09:56:12 +02:00
1 parent 23278318ef
commit d252940381
1 file changed
+29
+29
View File
@@ -153,6 +153,35 @@ test("a fresh arrival flips the day in place", async ({ page }) => {
).toBe(true);
}
// A night from earlier in the week, so this is a record that expects
// sleep at all. The digest waits for last night only when sleep actually
// reaches the account (a night inside the last seven days); without one
// the purge above leaves a record with no sleep source, which reads
// `final` by design and puts the provisional assertion below out of
// reach. Written through the same ingest route as the fresh night, and
// 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);
const priorBatch = await page.request.post("/api/measurements/batch", {
data: {
entries: [
{
hkIdentifier: "HKCategoryTypeIdentifierSleepAnalysis",
value: 420,
unit: "min",
startDate: priorNight.toISOString(),
endDate: priorWoke.toISOString(),
externalId: `e2e-just-in-prior-${priorNight.getTime()}`,
sleepStage: 3,
},
],
},
});
expect(
priorBatch.ok(),
`prior-night sleep batch must be accepted (got ${priorBatch.status()})`,
).toBe(true);
// The account needs a reason to paint a hero that is not the arrival
// itself. A connection needing a reconnect is that reason: the digest
// reads `integration_statuses` fresh on every request rather than