Skip to content

Commit

Permalink
Adding UI Test for Passwordless Flow [fdl deprecation] (#14000)
Browse files Browse the repository at this point in the history
  • Loading branch information
srushtisv authored Nov 4, 2024
1 parent 3e2c63d commit 060e31d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class PasswordlessViewController: OtherAuthViewController {

// MARK: - Firebase 🔥

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

private func sendSignInLink(to email: String) {
let actionCodeSettings = ActionCodeSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,35 @@ class AuthenticationExampleUITests: XCTestCase {
removeUIInterruptionMonitor(interruptionMonitor)
}

func testEmailLinkSentSuccessfully() {
app.staticTexts["Email Link/Passwordless"].tap()

let testEmail = "[email protected]"
app.textFields["Enter Authentication Email"].tap()
app.textFields["Enter Authentication Email"].typeText(testEmail)
app.buttons["return"].tap() // Dismiss keyboard
app.buttons["Send Sign In Link"].tap()

// Wait for the error message to appear (if there is an error)
let errorAlert = app.alerts.staticTexts["Error"]
let errorExists = errorAlert.waitForExistence(timeout: 5.0)

app.swipeDown(velocity: .fast)

// Assert that there is no error message (success case)
// The email sign in link is sent successfully if no error message appears
XCTAssertFalse(errorExists, "Error")

// Go back and check that there is no user that is signed in
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
wait(forElement: app.navigationBars["User"], timeout: 5.0)
XCTAssertEqual(
app.cells.count,
0,
"The user shouldn't be signed in and the user view should have no cells."
)
}

// MARK: - Private Helpers

private func signOut() {
Expand Down

0 comments on commit 060e31d

Please sign in to comment.