test: stabilize getPendingPosts seed timestamps#5823
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review once |
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the getPendingPosts test helper by ensuring seeded posts get distinct timestamps, preventing collisions on the posts(cache_id) unique index when multiple inserts occur within the same millisecond on fast CI runners.
Changes:
- Introduces a monotonic
seedCounterto make seededsentAt/receivedAt/syncedAttimestamps unique per insert. - Updates seeded
Post.idgeneration to align with the computed seed timestamp.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
LGTM — test-only fix mirroring the existing seedCounter pattern in getDeliveryPendingPosts.
Extended reasoning...
Overview
Single-file test change in packages/shared/src/db/queries.test.ts. Adds a monotonic seedCounter to getPendingPosts's seedPost helper so each seeded row gets a unique sentAt/receivedAt/syncedAt, avoiding cache_id unique-index collisions when inserts land inside the same millisecond on fast CI runners.
Security risks
None. Test-only change; no production code paths, auth, or data handling are touched.
Level of scrutiny
Minimal. This is a flaky-test stabilization that mirrors the exact same seedCounter pattern already in use in the sibling getDeliveryPendingPosts describe block in the same file. The change is small, mechanical, and self-contained.
Other factors
The id template still includes Math.random() so id uniqueness is preserved, and overrides.sentAt ?? t keeps callers' explicit sentAt values (used by tests that pin specific timestamps) intact. No behavior change for the assertions themselves.
Summary
OTT, Fixes a flaky
getPendingPoststest helper by giving seeded posts monotonic timestamps, avoiding accidental cache-key collisions on fast CI runners.Noticed after I pushed to #5813 and saw a test failure in CI.