Skip to content

fix: stop the follower grouping test failing just after midnight - #924

Merged
mnapoli merged 1 commit into
dev-null-sh:productionfrom
simonhamp:fix/flaky-follow-groups
Oct 22, 2026
Merged

mnapoli merged 1 commit into
dev-null-sh:productionfrom
simonhamp:fix/flaky-follow-groups

Conversation

@simonhamp

Copy link
Copy Markdown
Contributor

keeps stars and conversations apart while grouping followers in NotificationGroupsQueryTest fails when CI runs it between 00:01 and 00:02 UTC. It happened on #738 at 00:01 on 21 October, after production had passed the same code before midnight.

NotificationGroupsQuery never groups follows across days. The test makes its two follows 2 and 1 minutes before now, so in that minute they land on either side of midnight and come back as two followed groups instead of one.

The test now starts at noon. A pin at the top wasn't enough by itself: travelTo() with a callback sets the clock back to real time when the callback returns, not to the time set before it. So the first starAt() dropped the pin and the rest of the test ran on the real clock again. The starAt, replyAt and followAt helpers and the two mention lines now use Date::withTestNow(), which puts back whatever clock was set. (Rector prefers the Date facade to Carbon:: here.)

Things to look at

  • The other tests in this file now keep the frozen clock from Pest.php after calling a helper. Before, they ran on the real clock from the first helper call onward. They pass either way.
  • Two other tests make follows hours apart (counts unread groups that began before the oldest unread notification... and counts the same unread groups as grouping the whole history). Their follows can also fall on different days at some times of night, but their assertions hold either way, so I left them alone.

Testing

To check it without waiting for midnight, I faked the process clock for a run with a temporary Date::use() class whose now() adds an offset when no test clock is set. At a simulated 00:01:00, 00:01:30 and 00:01:59 UTC the old file fails with the same two followed groups as CI, and pinning the test without changing the helpers fails the same way. The fixed file passes at those times, at 02:40, 04:45 and 23:59:30, and on the real clock. Pint and Rector are clean.

@simonhamp
simonhamp marked this pull request as ready for review October 21, 2026 13:26
@mnapoli

mnapoli commented Oct 21, 2026

Copy link
Copy Markdown
Member

Are the failing tests related? Else sounds like an easy merge

@simonhamp

Copy link
Copy Markdown
Contributor Author

no, test fails here are because of the maintenance page

NotificationGroupsQuery never groups follows across days, and "keeps
stars and conversations apart while grouping followers" made its two
follows 2 and 1 minutes before now. Run between 00:01 and 00:02 UTC,
they land on different days and come back as two follow groups.

The test now starts at noon. Pinning the clock wasn't enough on its
own: travelTo() with a callback goes back to the real clock afterwards,
so the first starAt() dropped the pin. The helpers and the two mention
lines use Date::withTestNow() instead, which puts back whatever clock
was set before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp force-pushed the fix/flaky-follow-groups branch from 2736d2e to 5ed9f75 Compare October 22, 2026 10:38
@mnapoli
mnapoli merged commit 908250d into dev-null-sh:production Oct 22, 2026
5 checks passed
@simonhamp
simonhamp deleted the fix/flaky-follow-groups branch October 22, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants