@@ -82,15 +82,20 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
82
82
83
83
let signedInText = app. staticTexts [ " signed-in-text " ]
84
84
85
- let expectation = XCTNSPredicateExpectation (
86
- predicate: NSPredicate ( format: " exists == true " ) ,
87
- object: signedInText
88
- )
85
+ let expectation = XCTestExpectation ( description: " Wait for SignedInView to appear " )
89
86
87
+ let checkInterval : TimeInterval = 1
90
88
let maxWaitTime : TimeInterval = 30
91
- let result = XCTWaiter ( ) . wait ( for: [ expectation] , timeout: maxWaitTime)
92
89
93
- XCTAssertEqual ( result, . completed, " SignedInView should be visible after login " )
90
+ Timer . scheduledTimer ( withTimeInterval: checkInterval, repeats: true ) { timer in
91
+ if signedInText. exists {
92
+ expectation. fulfill ( )
93
+ timer. invalidate ( )
94
+ }
95
+ }
96
+
97
+ wait ( for: [ expectation] , timeout: maxWaitTime)
98
+ XCTAssertTrue ( signedInText. exists, " SignedInView should be visible after login " )
94
99
95
100
dismissAlert ( app: app)
96
101
// Check the Views are updated
@@ -184,14 +189,19 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
184
189
185
190
let signedInText = app. staticTexts [ " signed-in-text " ]
186
191
187
- let expectation = XCTNSPredicateExpectation (
188
- predicate: NSPredicate ( format: " exists == true " ) ,
189
- object: signedInText
190
- )
192
+ let expectation = XCTestExpectation ( description: " Wait for SignedInView to appear " )
191
193
194
+ let checkInterval : TimeInterval = 1
192
195
let maxWaitTime : TimeInterval = 30
193
- let result = XCTWaiter ( ) . wait ( for: [ expectation] , timeout: maxWaitTime)
194
196
195
- XCTAssertEqual ( result, . completed, " SignedInView should be visible after login " )
197
+ Timer . scheduledTimer ( withTimeInterval: checkInterval, repeats: true ) { timer in
198
+ if signedInText. exists {
199
+ expectation. fulfill ( )
200
+ timer. invalidate ( )
201
+ }
202
+ }
203
+
204
+ wait ( for: [ expectation] , timeout: maxWaitTime)
205
+ XCTAssertTrue ( signedInText. exists, " SignedInView should be visible after login " )
196
206
}
197
207
}
0 commit comments