Skip to content

Drive RepositoriesFeature timers with an injected clock#674

Merged
sbertix merged 1 commit into
mainfrom
sbertix/github-availability-test-clock
Jul 14, 2026
Merged

Drive RepositoriesFeature timers with an injected clock#674
sbertix merged 1 commit into
mainfrom
sbertix/github-availability-test-clock

Conversation

@sbertix

@sbertix sbertix commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

The build job was failing make test on a timing-sensitive test:
RepositoriesFeature slept on freshly constructed ContinuousClock()s inside
effects that TestStore has to drive, so on a saturated CI runner a receive
could blow past TCA's 1s timeout or the 15s recovery timer could fire an action
the test never asserted.

  • Inject \.continuousClock into RepositoriesFeature and route all three
    sleeps through it (15s GitHub-availability recovery loop, 2.5s success-toast
    auto-dismiss, 2s delayed pull-request refresh); drive the affected tests with
    a TestClock.
  • Add deterministic coverage for the recovery re-check across intervals, the
    toast auto-dismiss and re-arm, the .inProgress cancel path, and the
    delayed-refresh coalescing.
  • Fix PullRequestMergeQueueStatusTests, which pinned the abbreviated minute
    unit to an OS version ("min" below macOS 26.5, "mins" above) and so failed on
    26.5. Take the spelling from the formatter and assert the magnitude instead.
  • make test now writes a result bundle and prints each failure's assertion
    text on exit, since xcodebuild's streamed log reduces a parallel-bundle
    failure to a bare "Test case X failed" with no message.

Type of change

  • Bug fix
  • Feature
  • Documentation
  • Other

How was this tested?

  • make check passes (format + lint)
  • make test passes
  • I built and ran the app to confirm the change works

Not applicable: this is a test-infrastructure and reducer-clock change with no
runtime UI surface; it is exercised entirely through the test suite.

Checklist

  • I have read the Contributing guide and the Code of Conduct.

The GitHub-availability recovery loop, the success-toast auto-dismiss and the
delayed pull-request refresh each slept on a freshly constructed
ContinuousClock, so TestStore had to race real wall time. On a saturated CI
runner that made
worktreeInfoEventRepositoryPullRequestRefreshQueuesWhileAvailabilityUnknown
flaky: a `receive` could blow past TCA's 1s timeout, or the 15s recovery timer
could fire an action the test never asserted.

Inject `\.continuousClock` and route all three sleeps through it, and drive the
affected tests with a TestClock, with new deterministic coverage for the
recovery re-check across intervals, the toast auto-dismiss and re-arm, and the
delayed refresh.

While here, the sleeps now use `try await` instead of `try?` so cancellation
ends the effect directly rather than falling through to a send that TCA's own
`Send` guard would drop anyway; this lets the recovery loop shed its redundant
post-sleep cancellation check.

Two related fixes:

- PullRequestMergeQueueStatusTests pinned the abbreviated minute unit to an OS
  version ("min" below macOS 26.5, "mins" above), which is wrong on 26.5. Take
  the spelling from the formatter and assert the magnitude instead.
- `make test` now writes a result bundle and prints each failure's assertion
  text on exit, so a red build no longer shows a bare "Test case X failed".
@sbertix sbertix enabled auto-merge (squash) July 14, 2026 23:00
@sbertix sbertix merged commit 55b289b into main Jul 14, 2026
3 checks passed
@sbertix sbertix deleted the sbertix/github-availability-test-clock branch July 14, 2026 23:12
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.

1 participant