Skip to content

test: stabilize getPendingPosts seed timestamps#5823

Merged
patosullivan merged 1 commit into
developfrom
po/fix-getPendingPosts-test-helper
May 6, 2026
Merged

test: stabilize getPendingPosts seed timestamps#5823
patosullivan merged 1 commit into
developfrom
po/fix-getPendingPosts-test-helper

Conversation

@patosullivan
Copy link
Copy Markdown
Member

Summary

OTT, Fixes a flaky getPendingPosts test 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.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@patosullivan
Copy link
Copy Markdown
Member Author

@claude review once

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 seedCounter to make seeded sentAt/receivedAt/syncedAt timestamps unique per insert.
  • Updates seeded Post.id generation to align with the computed seed timestamp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@patosullivan patosullivan merged commit 32a8a3f into develop May 6, 2026
14 of 17 checks passed
@patosullivan patosullivan deleted the po/fix-getPendingPosts-test-helper branch May 6, 2026 14:58
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.

3 participants