Fix UI test failures: registration dismiss cascade, onboarding reset, test stability
- Fix registration flow dismiss cascade: chain fullScreenCover → sheet onDismiss so auth state is set only after all UIKit presentations are removed, preventing RootView from swapping LoginView→MainTabView behind a stale sheet - Fix onboarding reset: set hasCompletedOnboarding directly instead of calling completeOnboarding() which has an auth guard that fails after DataManager.clear() - Stabilize Suite1 registration tests, Suite6 task tests, Suite7 contractor tests - Add clean-slate-per-suite via AuthenticatedUITestCase reset state - Improve test account seeding and screen object reliability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -257,8 +257,6 @@ struct RegisterScreenObject {
|
||||
|
||||
private var usernameField: XCUIElement { app.textFields[UITestID.Auth.registerUsernameField] }
|
||||
private var emailField: XCUIElement { app.textFields[UITestID.Auth.registerEmailField] }
|
||||
private var passwordField: XCUIElement { app.secureTextFields[UITestID.Auth.registerPasswordField] }
|
||||
private var confirmPasswordField: XCUIElement { app.secureTextFields[UITestID.Auth.registerConfirmPasswordField] }
|
||||
private var registerButton: XCUIElement { app.buttons[UITestID.Auth.registerButton] }
|
||||
private var cancelButton: XCUIElement { app.buttons[UITestID.Auth.registerCancelButton] }
|
||||
|
||||
@@ -268,30 +266,32 @@ struct RegisterScreenObject {
|
||||
}
|
||||
|
||||
func fill(username: String, email: String, password: String) {
|
||||
func advanceToNextField() {
|
||||
let keys = ["Next", "Return", "return", "Done", "done"]
|
||||
for key in keys {
|
||||
let button = app.keyboards.buttons[key]
|
||||
if button.waitForExistence(timeout: 1) && button.isHittable {
|
||||
button.tap()
|
||||
return
|
||||
}
|
||||
// iOS 26 bug: SecureTextField won't gain keyboard focus when tapped directly.
|
||||
// Workaround: toggle password visibility first to convert SecureField → TextField,
|
||||
// then use focusAndType() on all regular TextFields.
|
||||
usernameField.waitForExistenceOrFail(timeout: 10)
|
||||
|
||||
// Scroll down to reveal the password toggle buttons (they're below the fold)
|
||||
let scrollView = app.scrollViews.firstMatch
|
||||
if scrollView.exists { scrollView.swipeUp() }
|
||||
|
||||
// Toggle both password visibility buttons (converts SecureField → TextField)
|
||||
let toggleButtons = app.buttons.matching(NSPredicate(format: "label == 'Toggle password visibility'"))
|
||||
for i in 0..<toggleButtons.count {
|
||||
let toggle = toggleButtons.element(boundBy: i)
|
||||
if toggle.exists && toggle.isHittable {
|
||||
toggle.tap()
|
||||
}
|
||||
}
|
||||
|
||||
usernameField.waitForExistenceOrFail(timeout: 10)
|
||||
// After toggling, password fields are regular TextFields.
|
||||
// Don't swipeDown — it dismisses the sheet. focusAndType() auto-scrolls via tap().
|
||||
let passwordField = app.textFields[UITestID.Auth.registerPasswordField]
|
||||
let confirmPasswordField = app.textFields[UITestID.Auth.registerConfirmPasswordField]
|
||||
|
||||
usernameField.focusAndType(username, app: app)
|
||||
advanceToNextField()
|
||||
|
||||
emailField.waitForExistenceOrFail(timeout: 10)
|
||||
emailField.focusAndType(email, app: app)
|
||||
advanceToNextField()
|
||||
|
||||
passwordField.waitForExistenceOrFail(timeout: 10)
|
||||
passwordField.focusAndType(password, app: app)
|
||||
advanceToNextField()
|
||||
|
||||
confirmPasswordField.waitForExistenceOrFail(timeout: 10)
|
||||
confirmPasswordField.focusAndType(password, app: app)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user