Skip to content

Phone login UI tests using reCAPTCHA Enterprise #14705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,57 @@
)
}

func testPhoneAuthLoginRCEInEnforceMode() {
app.staticTexts["Phone Number"].tap()
XCTAssertTrue(app.staticTexts["Sign in using Phone Auth"].waitForExistence(timeout: 3))
let testPhone = "12345678901"
app.textFields["Enter Phone Number"].tap()
app.textFields["Enter Phone Number"].typeText(testPhone)
app.buttons["Send Verification Code"].tap()
let verificationCodeInput = app.textFields["Enter verification code."]
let exists = verificationCodeInput.waitForExistence(timeout: 10)
XCTAssertTrue(exists, "Verification code field does not exist")

Check failure on line 194 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneAuthLoginRCEInEnforceMode, XCTAssertTrue failed - Verification code field does not exist

Check failure on line 194 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneAuthLoginRCEInEnforceMode, XCTAssertTrue failed - Verification code field does not exist

Check failure on line 194 in FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneAuthLoginRCEInEnforceMode, XCTAssertTrue failed - Verification code field does not exist
let testVerificationCode = "123456"
verificationCodeInput.typeText(testVerificationCode)
app.buttons["Continue"].tap()
// Sign out
let signOutButton = app.buttons["Sign Out"]
if signOutButton.exists {
signOutButton.tap()
}
}

func testPhoneAuthLoginRCEInEnforceModeIncorrectNumber() {
app.staticTexts["Phone Number"].tap()
XCTAssertTrue(app.staticTexts["Sign in using Phone Auth"].waitForExistence(timeout: 3))
let testPhone = "1234567890"
app.textFields["Enter Phone Number"].tap()
app.textFields["Enter Phone Number"].typeText(testPhone)
app.buttons["Send Verification Code"].tap()
// Verify that the error dialog appears
let errorDialog = app.alerts["Error"]
XCTAssertTrue(
errorDialog.waitForExistence(timeout: 5),
"Error dialog should appear."
)
let okButton = errorDialog.buttons["OK"] // Dismiss the error dialog
XCTAssertTrue(okButton.exists, "The 'OK' button should be present in the error dialog.")
okButton.tap()
// Ensure the dialog is dismissed
XCTAssertFalse(errorDialog.exists, "The error dialog should be dismissed after tapping 'OK'.")
// Go back and check that there is no user that is signed in
app.swipeDown(velocity: .fast)
// 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 DRAFT_testGoogleSignInAndLinkAccount() {
let interruptionMonitor = addUIInterruptionMonitor(withDescription: "Sign in with Google") {
alert -> Bool in
Expand Down Expand Up @@ -226,89 +277,6 @@
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."
)
}

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 = "[email protected]"
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 = "[email protected]"
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() {
Expand Down
Loading