From 2d26d0aada93c269cd909841db16c4b31a0bf38a Mon Sep 17 00:00:00 2001 From: khannurien Date: Fri, 9 Oct 2026 13:47:56 +0000 Subject: [PATCH] =?UTF-8?q?v4:=20the=20late-digest=20test=20no=20longer=20?= =?UTF-8?q?races=20the=20clock=20=E2=80=94=20it=20posted=20its=20only=20du?= =?UTF-8?q?mp=20at=20the=20current=20time=20and=20sent=20the=20digests=20r?= =?UTF-8?q?ight=20after,=20and=20a=20digest's=20window=20ends=20before=20t?= =?UTF-8?q?he=20run's=20`now`:=20when=20both=20fell=20in=20the=20same=20mi?= =?UTF-8?q?llisecond,=20which=20createUser's=20cached=20password=20hash=20?= =?UTF-8?q?made=20common,=20the=20dump=20was=20outside=20the=20week,=20the?= =?UTF-8?q?=20digest=20empty,=20and=20the=20test=20failed=20about=20one=20?= =?UTF-8?q?run=20in=20fifteen.=20Reproduced=20with=20a=20dump=20stamped=20?= =?UTF-8?q?at=20`now`=20(no=20digest)=20and=20one=20a=20millisecond=20earl?= =?UTF-8?q?ier=20(one);=20the=20dump=20is=20now=20dated=20a=20day=20back,?= =?UTF-8?q?=20as=20"recent"=20meant.=2060=20runs=20of=20the=20digest=20tes?= =?UTF-8?q?ts,=206=20of=20the=20backend=20suite=20(277=20tests)=20and=204?= =?UTF-8?q?=20of=20the=20frontend=20suite=20(684=20tests)=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- api/test/services/digest-service.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/test/services/digest-service.test.ts b/api/test/services/digest-service.test.ts index 6cffda7d..297c7592 100644 --- a/api/test/services/digest-service.test.ts +++ b/api/test/services/digest-service.test.ts @@ -302,7 +302,13 @@ test("sendDueDigests: an empty digest isn't sent, a late one covers the last per assert(windowOf(quiet.id, "weekly")! > ago(2 * DAY)); const late = await createUser({ createdAt: ago(60 * DAY) }); - const d = insertDump({ userId: quiet.id, title: "Recent" }); + // Dated in the past: a dump posted in the very millisecond the run takes + // as `now` falls outside the window, which ends before it. + const d = insertDump({ + userId: quiet.id, + title: "Recent", + createdAt: ago(DAY), + }); vote(d.id, 1); schedule(late.id, "weekly", ago(5 * PERIOD_MS.weekly)); const local = await createUser({