From 8d232b233fede2383ba1eb64f87a5cc7c6712602 Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Thu, 31 Oct 2024 00:39:57 +0530 Subject: [PATCH 1/2] adding UI test for reset password [fdl-dep] --- .../AuthenticationExampleUITests.swift | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index ac8d7953ae3..bc8e384ffb6 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -226,6 +226,60 @@ class AuthenticationExampleUITests: XCTestCase { removeUIInterruptionMonitor(interruptionMonitor) } + func testResetPasswordLinkCustomDomain() { + // assuming action type is in-app + continue URL everytime the app launches + + // set Authorized Domain as Continue URL + let testContinueURL = "fir-ios-auth-sample.firebaseapp.com" + app.staticTexts["Continue URL"].tap() + app.alerts.textFields.element.typeText(testContinueURL) + app.buttons["Save"].tap() + + // set Custom Hosting Domain as Link Domain + let testLinkDomain = "http://firebaseiosauthsample.testdomaindonotuse.com" + app.staticTexts["Link Domain"].tap() + app.alerts.textFields.element.typeText(testLinkDomain) + app.buttons["Save"].tap() + + app.staticTexts["Request Password Reset"].tap() + let testEmail = "test@test.com" + app.alerts.textFields.element.typeText(testEmail) + app.buttons["Save"].tap() + + // 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." + ) + } + + func testResetPasswordLinkDefaultDomain() { + // assuming action type is in-app + continue URL everytime the app launches + + // set Authorized Domain as Continue URL + let testContinueURL = "fir-ios-auth-sample.firebaseapp.com" + app.staticTexts["Continue URL"].tap() + app.alerts.textFields.element.typeText(testContinueURL) + app.buttons["Save"].tap() + + app.staticTexts["Request Password Reset"].tap() + let testEmail = "test@test.com" + app.alerts.textFields.element.typeText(testEmail) + app.buttons["Save"].tap() + + // 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 8e382f6e73d8a03f2bee548b16ff79b18ab93ea3 Mon Sep 17 00:00:00 2001 From: Srushti Vaidya Date: Fri, 8 Nov 2024 14:08:21 +0530 Subject: [PATCH 2/2] fix checks --- .../AuthenticationExampleUITests.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 12b2cceea32..d7c893d20c8 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -225,7 +225,7 @@ class AuthenticationExampleUITests: XCTestCase { // Cleanup removeUIInterruptionMonitor(interruptionMonitor) } - + func testEmailLinkSentSuccessfully() { app.staticTexts["Email Link/Passwordless"].tap() @@ -254,6 +254,7 @@ class AuthenticationExampleUITests: XCTestCase { "The user shouldn't be signed in and the user view should have no cells." ) } + func testResetPasswordLinkCustomDomain() { // assuming action type is in-app + continue URL everytime the app launches @@ -308,6 +309,22 @@ class AuthenticationExampleUITests: XCTestCase { ) } + // MARK: - Private Helpers + + private func signOut() { + if app.tabBars.firstMatch.buttons.element(boundBy: 1).exists { + app.tabBars.firstMatch.buttons.element(boundBy: 1).tap() + } + wait(forElement: app.navigationBars["User"], timeout: 5.0) + if app.staticTexts["Sign Out"].exists { + app.staticTexts["Sign Out"].tap() + } + if app.tabBars.firstMatch.buttons.element(boundBy: 0).exists { + app.tabBars.firstMatch.buttons.element(boundBy: 0).tap() + } + } +} + extension XCTestCase { func wait(forElement element: XCUIElement, timeout: TimeInterval) { let predicate = NSPredicate(format: "exists == 1")