UI test infrastructure overhaul — 58% to 96% pass rate (231/241)

Major infrastructure changes:
- BaseUITestCase: per-suite app termination via class setUp() prevents
  stale state when parallel clones share simulators
- relaunchBetweenTests override for suites that modify login/onboarding state
- focusAndType: dedicated SecureTextField path handles iOS strong password
  autofill suggestions (Choose My Own Password / Not Now dialogs)
- LoginScreenObject: tapSignUp/tapForgotPassword use scrollIntoView for
  offscreen buttons instead of simple swipeUp
- Removed all coordinate taps from ForgotPasswordScreen, VerifyResetCodeScreen,
  ResetPasswordScreen (Rule 3 compliance)
- Removed all usleep calls from screen objects (Rule 14 compliance)

App fixes exposed by tests:
- ContractorsListView: added onDismiss to sheet for list refresh after save
- AllTasksView: added Task.RefreshButton accessibility identifier
- AccessibilityIdentifiers: added Task.refreshButton
- DocumentsWarrantiesView: onDismiss handler for document list refresh
- Various form views: textContentType, submitLabel, onSubmit for keyboard flow

Test fixes:
- PasswordResetTests: handle auto-login after reset (app skips success screen)
- AuthenticatedUITestCase: refreshTasks() helper for kanban toolbar button
- All pre-login suites use relaunchBetweenTests for test independence
- Deleted dead code: AuthenticatedTestCase, SeededTestData, SeedTests,
  CleanupTests, old Suite0/2/3, Suite1_RegistrationRebuildTests

10 remaining failures: 5 iOS strong password autofill (simulator env),
3 pull-to-refresh gesture on empty lists, 2 feature coverage edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-03-23 15:05:37 -05:00
parent 0ca4a44bac
commit 4df8707b92
67 changed files with 3085 additions and 4853 deletions
+22 -13
View File
@@ -11,8 +11,6 @@ struct UITestHelpers {
/// Logs out the user if they are currently logged in
/// - Parameter app: The XCUIApplication instance
static func logout(app: XCUIApplication) {
sleep(1)
// Already on login screen.
let usernameField = loginUsernameField(app: app)
if usernameField.waitForExistence(timeout: 2) {
@@ -34,14 +32,12 @@ struct UITestHelpers {
let residencesTab = app.tabBars.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Residences'")).firstMatch
if residencesTab.exists {
residencesTab.tap()
sleep(1)
}
// Tap settings button
let settingsButton = app.buttons[AccessibilityIdentifiers.Navigation.settingsButton]
if settingsButton.waitForExistence(timeout: 3) && settingsButton.isHittable {
settingsButton.tap()
sleep(1)
}
// Find and tap logout button the profile sheet uses a lazy
@@ -100,8 +96,7 @@ struct UITestHelpers {
// Find username field by accessibility identifier
let usernameField = app.textFields[AccessibilityIdentifiers.Authentication.usernameField]
XCTAssertTrue(usernameField.waitForExistence(timeout: 5), "Username field should exist")
usernameField.tap()
usernameField.typeText(username)
usernameField.focusAndType(username, app: app)
// Find password field - it could be TextField (if visible) or SecureField
var passwordField = app.secureTextFields[AccessibilityIdentifiers.Authentication.passwordField]
@@ -109,22 +104,38 @@ struct UITestHelpers {
passwordField = app.textFields[AccessibilityIdentifiers.Authentication.passwordField]
}
XCTAssertTrue(passwordField.waitForExistence(timeout: 3), "Password field should exist")
passwordField.tap()
passwordField.typeText(password)
passwordField.focusAndType(password, app: app)
// Find and tap login button
let loginButton = app.buttons[AccessibilityIdentifiers.Authentication.loginButton]
XCTAssertTrue(loginButton.waitForExistence(timeout: 3), "Login button should exist")
loginButton.tap()
// Wait for login to complete
sleep(3)
// Wait for login to complete, handling verification gate if shown
let tabBarAfterLogin = app.tabBars.firstMatch
let verificationCodeField = app.textFields[AccessibilityIdentifiers.Authentication.verificationCodeField]
_ = tabBarAfterLogin.waitForExistence(timeout: 15)
|| verificationCodeField.waitForExistence(timeout: 3)
let onboardingCodeField = app.textFields[AccessibilityIdentifiers.Onboarding.verificationCodeField]
if verificationCodeField.waitForExistence(timeout: 3) || onboardingCodeField.waitForExistence(timeout: 2) {
let codeField = verificationCodeField.exists ? verificationCodeField : onboardingCodeField
codeField.focusAndType("123456", app: app)
let verifyButton = app.buttons[AccessibilityIdentifiers.Authentication.verifyButton].exists
? app.buttons[AccessibilityIdentifiers.Authentication.verifyButton]
: app.buttons[AccessibilityIdentifiers.Onboarding.verifyButton]
if verifyButton.exists {
verifyButton.tap()
} else {
app.buttons.containing(NSPredicate(format: "label CONTAINS[c] 'Verify'")).firstMatch.tap()
}
_ = tabBarAfterLogin.waitForExistence(timeout: 15)
}
}
/// Ensures the user is logged out before running a test
/// - Parameter app: The XCUIApplication instance
static func ensureLoggedOut(app: XCUIApplication) {
sleep(1)
logout(app: app)
ensureOnLoginScreen(app: app)
}
@@ -134,8 +145,6 @@ struct UITestHelpers {
/// - Parameter username: Optional username (defaults to "testuser")
/// - Parameter password: Optional password (defaults to "TestPass123!")
static func ensureLoggedIn(app: XCUIApplication, username: String = "testuser", password: String = "TestPass123!") {
sleep(1)
// Check if already logged in (tab bar visible)
let tabBar = app.tabBars.firstMatch
if tabBar.exists {