Skip to content

Commit 79a47f1

Browse files
test: update to use Swift .wait() method
1 parent e33f963 commit 79a47f1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

samples/swiftui/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
5858
}
5959

6060
@MainActor
61-
func testSignInDisplaysSignedInView() async throws {
61+
func testSignInDisplaysSignedInView() throws {
6262
let app = XCUIApplication()
6363
let email = createEmail()
6464
app.launchArguments.append("--auth-emulator")
@@ -82,11 +82,16 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
8282

8383
let signedInText = app.staticTexts["signed-in-text"]
8484

85-
XCTAssertTrue(
86-
signedInText.waitForExistence(timeout: 30),
87-
"SignedInView should be visible after login"
85+
let expectation = XCTNSPredicateExpectation(
86+
predicate: NSPredicate(format: "exists == true"),
87+
object: signedInText
8888
)
8989

90+
let maxWaitTime: TimeInterval = 30
91+
let result = XCTWaiter().wait(for: [expectation], timeout: maxWaitTime)
92+
93+
XCTAssertEqual(result, .completed, "SignedInView should be visible after login")
94+
9095
dismissAlert(app: app)
9196
// Check the Views are updated
9297
let signOutButton = app.buttons["sign-out-button"]
@@ -179,9 +184,14 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase {
179184

180185
let signedInText = app.staticTexts["signed-in-text"]
181186

182-
XCTAssertTrue(
183-
signedInText.waitForExistence(timeout: 30),
184-
"SignedInView should be visible after login"
187+
let expectation = XCTNSPredicateExpectation(
188+
predicate: NSPredicate(format: "exists == true"),
189+
object: signedInText
185190
)
191+
192+
let maxWaitTime: TimeInterval = 30
193+
let result = XCTWaiter().wait(for: [expectation], timeout: maxWaitTime)
194+
195+
XCTAssertEqual(result, .completed, "SignedInView should be visible after login")
186196
}
187197
}

0 commit comments

Comments
 (0)