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:
Trey T
2026-04-02 16:11:47 -05:00
parent 00e9ed0a96
commit 5bb27034aa
16 changed files with 277 additions and 232 deletions

View File

@@ -191,19 +191,35 @@ extension XCUIElement {
// SecureTextFields may trigger iOS strong password suggestion dialog
// which blocks the regular keyboard. Handle them with a dedicated path.
if elementType == .secureTextField {
// Dismiss any open keyboard first iOS 26 fails to transfer focus
// from a TextField to a SecureTextField if the keyboard is already up.
if app.keyboards.firstMatch.exists {
let navBar = app.navigationBars.firstMatch
if navBar.exists {
navBar.tap()
}
_ = app.keyboards.firstMatch.waitForNonExistence(timeout: 2)
}
tap()
// Dismiss "Choose My Own Password" or "Not Now" if iOS suggests a strong password
let chooseOwn = app.buttons["Choose My Own Password"]
if chooseOwn.waitForExistence(timeout: 1) {
if chooseOwn.waitForExistence(timeout: 0.5) {
chooseOwn.tap()
} else {
let notNow = app.buttons["Not Now"]
if notNow.exists && notNow.isHittable { notNow.tap() }
}
if app.keyboards.firstMatch.waitForExistence(timeout: 2) {
// Wait for keyboard after tapping SecureTextField
if !app.keyboards.firstMatch.waitForExistence(timeout: 5) {
// Retry tap first tap may not have acquired focus
tap()
_ = app.keyboards.firstMatch.waitForExistence(timeout: 3)
}
if app.keyboards.firstMatch.exists {
typeText(text)
} else {
app.typeText(text)
XCTFail("Keyboard did not appear after tapping SecureTextField: \(self)", file: file, line: line)
}
return
}