Skip to content

Commit 060e31d

Browse files
authored
Adding UI Test for Passwordless Flow [fdl deprecation] (#14000)
1 parent 3e2c63d commit 060e31d

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ class PasswordlessViewController: OtherAuthViewController {
3131

3232
// MARK: - Firebase 🔥
3333

34-
private let authorizedDomain: String = "ENTER AUTHORIZED DOMAIN"
35-
private let customDomain: String = "ENTER AUTHORIZED HOSTING DOMAIN"
34+
private let authorizedDomain: String =
35+
"fir-ios-auth-sample.firebaseapp.com" // Enter AUTHORIZED_DOMAIN
36+
private let customDomain: String =
37+
"firebaseiosauthsample.testdomaindonotuse.com" // Enter AUTHORIZED_HOSTING_DOMAIN
3638

3739
private func sendSignInLink(to email: String) {
3840
let actionCodeSettings = ActionCodeSettings()

FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,35 @@ class AuthenticationExampleUITests: XCTestCase {
226226
removeUIInterruptionMonitor(interruptionMonitor)
227227
}
228228

229+
func testEmailLinkSentSuccessfully() {
230+
app.staticTexts["Email Link/Passwordless"].tap()
231+
232+
let testEmail = "[email protected]"
233+
app.textFields["Enter Authentication Email"].tap()
234+
app.textFields["Enter Authentication Email"].typeText(testEmail)
235+
app.buttons["return"].tap() // Dismiss keyboard
236+
app.buttons["Send Sign In Link"].tap()
237+
238+
// Wait for the error message to appear (if there is an error)
239+
let errorAlert = app.alerts.staticTexts["Error"]
240+
let errorExists = errorAlert.waitForExistence(timeout: 5.0)
241+
242+
app.swipeDown(velocity: .fast)
243+
244+
// Assert that there is no error message (success case)
245+
// The email sign in link is sent successfully if no error message appears
246+
XCTAssertFalse(errorExists, "Error")
247+
248+
// Go back and check that there is no user that is signed in
249+
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
250+
wait(forElement: app.navigationBars["User"], timeout: 5.0)
251+
XCTAssertEqual(
252+
app.cells.count,
253+
0,
254+
"The user shouldn't be signed in and the user view should have no cells."
255+
)
256+
}
257+
229258
// MARK: - Private Helpers
230259

231260
private func signOut() {

0 commit comments

Comments
 (0)