mirror of
https://github.com/block/buzz.git
synced 2026-11-25 02:31:36 +00:00
## Summary Fixes a flaky native iOS test, `RunnerTests.testNavigationGlassMergesAndRestoresInBothDirections`. Test-only: one file, `mobile/ios/RunnerTests/RunnerTests.swift`. ### Failure "Mobile Swift Domain / Mobile Swift (Native)" failed on #9780 ([run 44682658228](https://github.com/block/buzz/actions/runs/44682658228/job/136109857758)): ``` mobile/ios/RunnerTests/RunnerTests.swift:83: error: -[RunnerTests.RunnerTests testNavigationGlassMergesAndRestoresInBothDirections] : Asynchronous wait failed: Exceeded timeout of 2 seconds, with unfulfilled expectations: "Expect predicate BLOCKPREDICATE(...)" ``` ### Why it is a flake - #9780 changes only Dart files under `mobile/lib/features/channels` and one Dart test. Nothing in it reaches `MergingNavigationGlass`. - The same job passed on another PR minutes later ([run 44683133967](https://github.com/block/buzz/actions/runs/44683133967)) and passes on most pushes to `main`. - No open PR or commit on `main` already addresses this test. #9260, #9574 and #9725 touch `RunnerTests.swift` but not this test or its waits. ### Cause `setMenuOpen(true)` starts a 0.18 s `UIViewPropertyAnimator`. The test then waited up to 2 s for both side surfaces to reach alpha 0, using `XCTNSPredicateExpectation`. That expectation evaluates its predicate about once a second. The evidence is in the passing run: the test takes 4.07 s for four waits on a 0.18 s animation, about 1 s per wait. A 2 s timeout therefore gets one or two evaluations. RunnerTests runs inside the Flutter app, and when the app holds the main thread across those evaluations the wait expires although the animation finished long before. In the failing run the 2 s timeout was reported 5.2 s after the test started, and the test's three remaining waits then passed at about 1 s each. This is inferred from the CI timings and the code. It was not reproduced. ### Fix Both waits now use a small `waitUntil` helper in the existing `XCTestCase` extension. It checks the condition every 10 ms on the main actor, for up to 10 s (the budget the other RunnerTests callbacks use since #8678 and #8741). It checks the condition before the deadline on every pass, so a main-thread stall of any length is followed by one more check instead of a timeout. The two conditions and every assertion after them are unchanged. If the surfaces never merge or restore, the test still fails, at the calling line. As a side effect the test should take about 0.4 s instead of 4 s. ### Not included `BuzzPushNotificationResolverTests.testShownMessagesStayShownAcrossCommunitiesFailuresAndBursts` also failed once on `main` with a 2 s timeout ([run 44682614076](https://github.com/block/buzz/actions/runs/44682614076/job/136109821029)). It is a different mechanism: an `XCTestExpectation` fulfilled by the resolver's own completion, across about 145 resolver runs, in the macOS `swift test` step. The only available change is a longer timeout in a helper shared by the whole class, and the cause of the slow run is not established, so it is left out. ### Testing - **Not compiled against the app and not run on a simulator.** A local simulator build was started and then abandoned; the machine was heavily loaded. `swiftc -parse` accepts the file. - **The Mobile Swift (Native) lane on this PR is the first place the change compiles and runs.** - Pushed with `git push --no-verify`. `buzz-review-completed` is not added: agent review and human testing (AGENTS.md "Before opening a PR") have not happened. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Matt Toohey <contact@matttoohey.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>