test(mobile): match the hop diagnostic's doc to its output, use it for every reply

Two optional suggestions from the final review of 93d426da1.

The `waitForCallback` doc comment quoted example failures the helper cannot
print: the hop is capped at 2 s, so "took 7.2 s" never occurs, and durations
print as "%.1f ms". It now quotes the real forms ("did not finish within
2 s", hundreds of ms, "took 0.4 ms"), states that the hop is measured after
the 10 s window so a fast hop does not rule out starvation that ended at
the deadline, and presents the 2026-11-01 diagnosis as an inference, since
the measurement did not exist in those runs.

`testAllowedNotificationRestoreNeedsNoAppGroupStore` used a plain
`wait(for:)`; it now goes through `waitForCallback`, so every bridge-reply
wait in the class carries the hop report.

Verification: class in isolation green once (6 tests, 0.05 s); `git diff
--check` clean; the commit touches only this file, with no Podfile.lock,
xcshareddata, or Dart changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
This commit is contained in:
Matt Toohey
2026-11-02 13:35:45 +11:00
parent 6cc43c9fd4
commit e5515f7657

View File

@@ -250,11 +250,14 @@ final class BuzzPushSnapshotEnrichmentTests: XCTestCase {
/// Waits for a bridge callback. On timeout the failure also reports how long
/// one fresh user-initiated-queue-then-main-queue hop takes right then (the
/// path every bridge reply follows), so a starved test host ("hop took 7.2 s")
/// reads differently from a callback that never fired ("hop took 12 ms").
/// Both 2026-11-01 CI failures were the former: the RunnerTests host is the
/// full Flutter app, and its launch saturated the 3-vCPU runner mid-class.
/// A passing wait returns as soon as the callback runs and measures nothing.
/// path every bridge reply follows), capped at 2 s. A starved test host reads
/// "a fresh queue->main hop did not finish within 2 s" or hundreds of ms; a
/// callback that never fired reads "took 0.4 ms". The hop is measured after
/// the 10 s window, so a fast hop does not rule out starvation that ended at
/// the deadline. The 2026-11-01 CI failures predate this measurement; their
/// timings fit starvation, since the RunnerTests host is the full Flutter app
/// and its launch saturated the 3-vCPU runner mid-class. A passing wait
/// returns as soon as the callback runs and measures nothing.
private func waitForCallback(
_ expectation: XCTestExpectation, file: StaticString = #filePath, line: UInt = #line
) {
@@ -341,7 +344,7 @@ final class BuzzPushSnapshotEnrichmentTests: XCTestCase {
received = value
completed.fulfill()
})
wait(for: [completed], timeout: callbackTimeout)
waitForCallback(completed)
XCTAssertNil(received)
}