From 060e31de0fda486dee1185a5df61df0cc567c57a Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Mon, 4 Nov 2024 22:45:32 +0530 Subject: [PATCH] Adding UI Test for Passwordless Flow [fdl deprecation] (#14000) --- .../PasswordlessViewController.swift | 6 ++-- .../AuthenticationExampleUITests.swift | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift index ba67023a2d8..da700ab518e 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift @@ -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() diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index ac8d7953ae3..791b5c7a2b5 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -226,6 +226,35 @@ class AuthenticationExampleUITests: XCTestCase { removeUIInterruptionMonitor(interruptionMonitor) } + func testEmailLinkSentSuccessfully() { + app.staticTexts["Email Link/Passwordless"].tap() + + let testEmail = "test@test.com" + 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() {