Fix AccessibilityTests hang on previews expecting expired transient state

The Observation migration (2d486ece3) ported the preview fulfillment loop
from Combine publishers to async sequences but didn't carry over the
publisher path's 1s timeout. Without it, a preview whose expected state never
arrives loops forever.
This commit is contained in:
Stefan Ceriu
2026-07-01 10:23:45 +03:00
parent 036c9ce248
commit f7a4f8a2b4
@@ -149,8 +149,14 @@ struct PreviewsWrapperView: View {
.makeAsyncIterator()
while let value = await iterator.next(isolation: #isolation), value == false { }
case .sequence(let sequence):
var iterator = sequence.makeAsyncIterator()
while let value = await iterator.next(isolation: #isolation), value == false { }
// Mirror the publisher timeout above so a preview expecting a state that never
// arrives (e.g. a transient one that already expired) doesn't hang the suite.
let task = Task {
var iterator = sequence.makeAsyncIterator()
while let value = await iterator.next(isolation: #isolation), value == false { }
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { task.cancel() }
await task.value
case .none:
break
}