Skip to content

Commit 2b31a9f

Browse files
committed
adding mfa ui test (enforce mode)
1 parent 454f399 commit 2b31a9f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,44 @@ class AuthenticationExampleUITests: XCTestCase {
182182
)
183183
}
184184

185+
func testPhoneMultiFactorEnrollUnenrollTest() {
186+
// login with email password
187+
app.staticTexts["Email & Password Login"].tap()
188+
let testEmail = "[email protected]"
189+
app.textFields["Email"].tap()
190+
app.typeText(testEmail)
191+
app.buttons["return"].tap() // Dismiss keyboard
192+
let testPassword = "sampleauthios"
193+
app.textFields["Password"].tap()
194+
app.typeText(testPassword)
195+
app.buttons["return"].tap() // Dismiss keyboard
196+
app.buttons["Login"].tap()
197+
// enroll with phone
198+
app.tabBars.buttons["Authentication"].tap()
199+
app.tables.cells.staticTexts["Phone Enroll"].tap()
200+
let testPhone = "+11234567890"
201+
app.typeText(testPhone)
202+
app.buttons["Save"].tap()
203+
let testVerificationCode = "123456"
204+
app.typeText(testVerificationCode)
205+
app.buttons["Save"].tap()
206+
let testPhoneSecondFactorDisplayName = "phone1"
207+
app.typeText(testPhoneSecondFactorDisplayName)
208+
app.buttons["Save"].tap()
209+
// unenroll
210+
app.swipeUp(velocity: .fast)
211+
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
212+
XCTAssertTrue(app.buttons["phone1"].exists) // enrollment successful
213+
app.buttons["phone1"].tap()
214+
app.swipeUp(velocity: .fast)
215+
app.tables.cells.staticTexts["Multifactor unenroll"].tap()
216+
XCTAssertFalse(app.buttons["phone1"].exists) // unenrollment successful
217+
app.buttons["Cancel"].tap()
218+
// Sign out explicitly after unenroll
219+
app.tabBars.buttons["Current User"].tap()
220+
app.tabBars.firstMatch.buttons.element(boundBy: 1).tap()
221+
}
222+
185223
func DRAFT_testGoogleSignInAndLinkAccount() {
186224
let interruptionMonitor = addUIInterruptionMonitor(withDescription: "Sign in with Google") {
187225
alert -> Bool in

0 commit comments

Comments
 (0)