@@ -182,7 +182,7 @@ class AuthenticationExampleUITests: XCTestCase {
182182 )
183183 }
184184
185- func testPhoneMultiFactorEnrollUnenrollTest ( ) {
185+ func testPhoneMultiFactorEnrollUnenroll ( ) {
186186 // login with email password
187187 app. staticTexts [ " Email & Password Login " ] . tap ( )
188188 let testEmail = " [email protected] " @@ -194,19 +194,19 @@ class AuthenticationExampleUITests: XCTestCase {
194194 app. typeText ( testPassword)
195195 app. buttons [ " return " ] . tap ( ) // Dismiss keyboard
196196 app. buttons [ " Login " ] . tap ( )
197- // enroll with phone
197+ // enroll multifactor with phone
198198 app. tabBars. buttons [ " Authentication " ] . tap ( )
199199 app. tables. cells. staticTexts [ " Phone Enroll " ] . tap ( )
200- let testPhone = " +11234567890 "
201- app. typeText ( testPhone )
200+ let testSecondFactorPhone = " +11234567890 "
201+ app. typeText ( testSecondFactorPhone )
202202 app. buttons [ " Save " ] . tap ( )
203203 let testVerificationCode = " 123456 "
204204 app. typeText ( testVerificationCode)
205205 app. buttons [ " Save " ] . tap ( )
206206 let testPhoneSecondFactorDisplayName = " phone1 "
207207 app. typeText ( testPhoneSecondFactorDisplayName)
208208 app. buttons [ " Save " ] . tap ( )
209- // unenroll
209+ // unenroll multifactor
210210 app. swipeUp ( velocity: . fast)
211211 app. tables. cells. staticTexts [ " Multifactor unenroll " ] . tap ( )
212212 XCTAssertTrue ( app. buttons [ " phone1 " ] . exists) // enrollment successful
@@ -215,11 +215,44 @@ class AuthenticationExampleUITests: XCTestCase {
215215 app. tables. cells. staticTexts [ " Multifactor unenroll " ] . tap ( )
216216 XCTAssertFalse ( app. buttons [ " phone1 " ] . exists) // unenrollment successful
217217 app. buttons [ " Cancel " ] . tap ( )
218- // Sign out explicitly after unenroll
218+ // Sign out after unenroll
219219 app. tabBars. buttons [ " Current User " ] . tap ( )
220220 app. tabBars. firstMatch. buttons. element ( boundBy: 1 ) . tap ( )
221221 }
222222
223+ func testPhoneSecondFactorSignIn( ) {
224+ // login with email password
225+ app. staticTexts [ " Email & Password Login " ] . tap ( )
226+ let testEmail = " [email protected] " 227+ app. textFields [ " Email " ] . tap ( )
228+ app. typeText ( testEmail)
229+ app. buttons [ " return " ] . tap ( ) // Dismiss keyboard
230+ let testPassword = " sampleios123 "
231+ app. textFields [ " Password " ] . tap ( )
232+ app. typeText ( testPassword)
233+ app. buttons [ " return " ] . tap ( ) // Dismiss keyboard
234+ app. buttons [ " Login " ] . tap ( )
235+ // login with second factor
236+ XCTAssertTrue ( app. staticTexts [ " Choose a second factor to continue. " ] . waitForExistence ( timeout: 5 ) )
237+ let secondFactor = app. staticTexts [ " phone2 " ] // Select 'phone2' from the modal list
238+ XCTAssertTrue ( secondFactor. exists, " 'phone2' option should be visible in the modal. " )
239+ secondFactor. tap ( )
240+ app. buttons [ " Send Verification Code " ] . tap ( )
241+ let verificationCodeInput = app. textFields [ " Enter verification code. " ]
242+ XCTAssertTrue ( verificationCodeInput. waitForExistence ( timeout: 2 ) , " OTP input field should appear. " ) // Wait for the OTP input field to appear
243+ verificationCodeInput. tap ( )
244+ let testVerificationCode = " 123456 "
245+ verificationCodeInput. typeText ( testVerificationCode)
246+ let signInButton = app. buttons [ " Sign in " ]
247+ XCTAssertTrue ( signInButton. waitForExistence ( timeout: 2 ) , " 'Sign in' button should be visible. " )
248+ signInButton. tap ( )
249+ // sign out
250+ let signOutButton = app. buttons [ " Sign Out " ]
251+ if signOutButton. exists {
252+ signOutButton. tap ( )
253+ }
254+ }
255+
223256 func DRAFT_testGoogleSignInAndLinkAccount( ) {
224257 let interruptionMonitor = addUIInterruptionMonitor ( withDescription: " Sign in with Google " ) {
225258 alert -> Bool in
0 commit comments