Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,76 @@
)
}

func testPhoneMultiFactorEnrollUnenroll() {
// login with email password
app.staticTexts["Email & Password Login"].tap()
let testEmail = "[email protected]"
app.textFields["Email"].tap()
app.typeText(testEmail)
let testPassword = "sampleauthios"
app.textFields["Password"].tap()
app.typeText(testPassword)
app.buttons["Login"].tap()
// enroll multifactor with phone
let authenticationButton = app.tabBars.buttons["Authentication"]
let exists = authenticationButton.waitForExistence(timeout: 5)
XCTAssertTrue(exists, "Authentication button did not appear in time.")
authenticationButton.tap()
app.tables.cells.staticTexts["Phone Enroll"].tap()
let testSecondFactorPhone = "+11234567890"
app.typeText(testSecondFactorPhone)
app.buttons["Save"].tap()
let testVerificationCode = "123456"
app.typeText(testVerificationCode)

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 13683, label: 'AuthenticationExample'

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 23476, label: 'AuthenticationExample'

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneMultiFactorEnrollUnenroll, Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: Application, pid: 33708, label: 'AuthenticationExample'
app.buttons["Save"].tap()
let testPhoneSecondFactorDisplayName = "phone1"
app.typeText(testPhoneSecondFactorDisplayName)
app.buttons["Save"].tap()
// unenroll multifactor
app.swipeUp(velocity: .fast)
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertTrue(app.buttons["phone1"].exists) // enrollment successful
app.buttons["phone1"].tap()
app.swipeUp(velocity: .fast)
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
XCTAssertFalse(app.buttons["phone1"].exists) // unenrollment successful
app.buttons["Cancel"].tap()
// sign out after unenroll
app.tabBars.buttons["Current User"].tap()
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
}

func testPhoneSecondFactorSignIn() {
// login with email password
app.staticTexts["Email & Password Login"].tap()
let testEmail = "[email protected]"
app.textFields["Email"].tap()
app.typeText(testEmail)
let testPassword = "sampleios123"
app.textFields["Password"].tap()
app.typeText(testPassword)
app.buttons["Login"].tap()
// login with second factor
XCTAssertTrue(app.staticTexts["Choose a second factor to continue."]
.waitForExistence(timeout: 5))
let secondFactor = app.staticTexts["phone2"] // select 'phone2' as second factor
XCTAssertTrue(secondFactor.exists, "'phone2' option should be visible.")
secondFactor.tap()
app.buttons["Send Verification Code"].tap()
let verificationCodeInput = app.textFields["Enter verification code."]
verificationCodeInput.tap()

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, Failed to tap "Enter verification code." TextField: No matches found for Elements matching predicate '"Enter verification code." IN identifiers' from input {(

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, Failed to tap "Enter verification code." TextField: No matches found for Elements matching predicate '"Enter verification code." IN identifiers' from input {(

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

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

testPhoneSecondFactorSignIn, Failed to tap "Enter verification code." TextField: No matches found for Elements matching predicate '"Enter verification code." IN identifiers' from input {(
let testVerificationCode = "123456"
verificationCodeInput.typeText(testVerificationCode)
let signInButton = app.buttons["Sign in"]
XCTAssertTrue(signInButton.waitForExistence(timeout: 2), "'Sign in' button should be visible.")
signInButton.tap()
// sign out
let signOutButton = app.buttons["Sign Out"]
if signOutButton.exists {
signOutButton.tap()
}
}

func DRAFT_testGoogleSignInAndLinkAccount() {
let interruptionMonitor = addUIInterruptionMonitor(withDescription: "Sign in with Google") {
alert -> Bool in
Expand Down
Loading