waitConfirmation implementation (#5130)

* `waitConfirmation` implementation

* even better docs

* made the body not async since the context of usage did not really require it

* pr suggestions
This commit is contained in:
Mauro
2026-02-23 14:24:19 +01:00
committed by GitHub
parent 546a71df0c
commit 6f1720da89
8 changed files with 262 additions and 77 deletions
@@ -162,26 +162,17 @@ struct PollFormScreenViewModelTests {
let deferred = deferFulfillment(viewModel.actions) { $0 == .close }
try await confirmation { confirmation in
var redactReasonCalled = false
await waitForConfirmation(timeout: .seconds(1)) { confirmation in
timelineProxy.redactReasonClosure = { eventID, _ in
defer {
confirmation()
redactReasonCalled = true
}
#expect(eventID == .eventID("foo"))
return .success(())
}
context.alertInfo?.secondaryButton?.action?()
try await deferred.fulfill()
// Since the redactReasonClosure is called asynchronously after closing the alert
// We need to actively wait for the redactReasonClosure to be called before fulfilling the test.
while !redactReasonCalled {
await Task.yield()
}
}
try await deferred.fulfill()
}
// MARK: - Helpers