From 16a3a6133314f4dc000893dace01695be15b4e27 Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Thu, 31 Oct 2024 00:49:30 +0530 Subject: [PATCH 1/4] test to verify email link sent successfully --- .../AuthenticationExampleUITests.swift | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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() { From b780d54fa2d537997bd3c7fcad52c8335fd87e06 Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Thu, 31 Oct 2024 22:03:42 +0530 Subject: [PATCH 2/4] updating domain --- .../PasswordlessViewController.swift | 4 ++-- 1 file changed, 2 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..ad85934eb76 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift @@ -31,7 +31,7 @@ class PasswordlessViewController: OtherAuthViewController { // MARK: - Firebase 🔥 - private let authorizedDomain: String = "ENTER AUTHORIZED DOMAIN" + private let authorizedDomain: String = "fir-ios-auth-sample.firebaseapp.com" private let customDomain: String = "ENTER AUTHORIZED HOSTING DOMAIN" private func sendSignInLink(to email: String) { @@ -43,7 +43,7 @@ class PasswordlessViewController: OtherAuthViewController { // The sign-in operation must be completed in the app. actionCodeSettings.handleCodeInApp = true actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!) - actionCodeSettings.linkDomain = customDomain +// actionCodeSettings.linkDomain = customDomain AppManager.shared.auth() .sendSignInLink(toEmail: email, actionCodeSettings: actionCodeSettings) { error in From 59f71532ab43b05d652659d47c7a7407153c9287 Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Fri, 1 Nov 2024 00:42:02 +0530 Subject: [PATCH 3/4] fixes --- .../AuthenticationExampleUITests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 791b5c7a2b5..3f09c5e20c2 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -232,7 +232,7 @@ class AuthenticationExampleUITests: XCTestCase { 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["return"].tap() // Dismiss keyboard app.buttons["Send Sign In Link"].tap() // Wait for the error message to appear (if there is an error) From be11a765140aa3eeb91d8ef98b950b417456f29d Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Fri, 1 Nov 2024 06:04:35 +0530 Subject: [PATCH 4/4] custom domain test --- .../PasswordlessViewController.swift | 8 +++++--- .../AuthenticationExampleUITests.swift | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/OtherAuthMethodControllers/PasswordlessViewController.swift index ad85934eb76..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 = "fir-ios-auth-sample.firebaseapp.com" - 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() @@ -43,7 +45,7 @@ class PasswordlessViewController: OtherAuthViewController { // The sign-in operation must be completed in the app. actionCodeSettings.handleCodeInApp = true actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!) -// actionCodeSettings.linkDomain = customDomain + actionCodeSettings.linkDomain = customDomain AppManager.shared.auth() .sendSignInLink(toEmail: email, actionCodeSettings: actionCodeSettings) { error in diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 3f09c5e20c2..791b5c7a2b5 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -232,7 +232,7 @@ class AuthenticationExampleUITests: XCTestCase { 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["return"].tap() // Dismiss keyboard app.buttons["Send Sign In Link"].tap() // Wait for the error message to appear (if there is an error)