v4: the late-digest test no longer races the clock — it posted its only dump at the current time and sent the digests right after, and a digest's window ends before the run's now: when both fell in the same millisecond, which createUser's cached password hash made common, the dump was outside the week, the digest empty, and the test failed about one run in fifteen. Reproduced with a dump stamped at now (no digest) and one a millisecond earlier (one); the dump is now dated a day back, as "recent" meant. 60 runs of the digest tests, 6 of the backend suite (277 tests) and 4 of the frontend suite (684 tests) pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-10-09 13:47:56 +00:00
parent fac0e2db28
commit 2d26d0aada

View File

@@ -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({