@@ -193,11 +193,24 @@ final class MFAEnrollmentUITests: XCTestCase {
193193 XCTAssertTrue ( startButton. waitForExistence ( timeout: 10 ) )
194194 startButton. tap ( )
195195
196- // 6) Enter phone number and display name, then press "Send Code"
196+ // 6) Select UK country code and enter phone number (without dial code)
197+ // Find and tap the country selector - try multiple approaches since it's embedded in the TextField
198+ let countrySelector = app. buttons [ " 🇺🇸 +1 " ]
199+ XCTAssertTrue ( countrySelector. waitForExistence ( timeout: 5 ) )
200+
201+ countrySelector. tap ( )
202+
203+ // Select United Kingdom (+44) - try multiple element types
204+ let ukOption = app. buttons [ " country-option-GB " ]
205+ XCTAssertTrue ( ukOption. waitForExistence ( timeout: 5 ) )
206+
207+ ukOption. tap ( )
208+
209+ // Enter phone number (without dial code)
197210 let phoneField = app. textFields [ " phone-number-field " ]
198211 XCTAssertTrue ( phoneField. waitForExistence ( timeout: 10 ) )
199- let phoneNumber = " +447444555666 "
200- UIPasteboard . general. string = phoneNumber
212+ let phoneNumberWithoutDialCode = " 7444555666 "
213+ UIPasteboard . general. string = phoneNumberWithoutDialCode
201214 phoneField. tap ( )
202215 phoneField. press ( forDuration: 1.2 )
203216 app. menuItems [ " Paste " ] . tap ( )
@@ -219,7 +232,9 @@ final class MFAEnrollmentUITests: XCTestCase {
219232 XCTAssertTrue ( verificationCodeField. waitForExistence ( timeout: 15 ) )
220233
221234 // Fetch the latest SMS verification code generated by the emulator for this phone number
222- let code = try await getLastSmsCode ( specificPhone: phoneNumber)
235+ // The emulator stores the full phone number with dial code
236+ let fullPhoneNumber = " +44 \( phoneNumberWithoutDialCode) "
237+ let code = try await getLastSmsCode ( specificPhone: fullPhoneNumber)
223238
224239 UIPasteboard . general. string = code
225240 verificationCodeField. tap ( )
@@ -356,48 +371,17 @@ final class MFAEnrollmentUITests: XCTestCase {
356371 try navigateToMFAEnrollment ( app: app)
357372
358373 // Test back button exists
359- let cancelButton = app. buttons [ " mfa-back-button " ]
360- XCTAssertTrue ( cancelButton. exists, " Back button should exist " )
361- XCTAssertTrue ( cancelButton. isEnabled, " Back button should be enabled " )
374+ let backButton = app. navigationBars. buttons. element ( boundBy: 0 )
375+ XCTAssertTrue ( backButton. exists, " Back button should exist " )
362376
363377 // Tap cancel button
364- cancelButton. tap ( )
365-
366- // Should navigate back to signed in view
367- let signedInText = app. staticTexts [ " signed-in-text " ]
368- XCTAssertTrue (
369- signedInText. waitForExistence ( timeout: 5 ) ,
370- " Should navigate back to signed in view "
371- )
372- }
373-
374- @MainActor
375- func testBackButtonFromMFAManagement( ) async throws {
376- let email = createEmail ( )
377-
378- // Create user in test runner before launching app
379- try await createTestUser ( email: email)
380-
381- let app = createTestApp ( mfaEnabled: true )
382- app. launch ( )
383-
384- // Sign in and navigate to MFA management
385- try signInToApp ( app: app, email: email)
386- app. buttons [ " mfa-management-button " ] . tap ( )
387-
388- // Test back button exists
389- let backButton = app. buttons [ " back-button " ]
390- XCTAssertTrue ( backButton. waitForExistence ( timeout: 5 ) , " Back button should exist " )
391- XCTAssertTrue ( backButton. isEnabled, " Back button should be enabled " )
392-
393- // Tap back button
394378 backButton. tap ( )
395379
396- // Should navigate back to signed in view
397- let signedInText = app. staticTexts [ " signed-in-text " ]
380+ // Should navigate back to manage MFA View
381+ let signedInText = app. buttons [ " setup-mfa-button " ]
398382 XCTAssertTrue (
399383 signedInText. waitForExistence ( timeout: 5 ) ,
400- " Should navigate back to signed in view "
384+ " Should navigate back to setup MFA view "
401385 )
402386 }
403387
0 commit comments