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:
@@ -3,6 +3,8 @@ import XCTest
|
||||
/// Rebuild plan for legacy: Suite0_OnboardingTests.test_onboarding
|
||||
/// Split into smaller tests to isolate focus/input/navigation failures.
|
||||
final class Suite0_OnboardingRebuildTests: BaseUITestCase {
|
||||
override var relaunchBetweenTests: Bool { true }
|
||||
|
||||
func testR001_onboardingWelcomeLoadsAndCanNavigateToLoginEntry() {
|
||||
let welcome = OnboardingWelcomeScreen(app: app)
|
||||
welcome.waitForLoad(timeout: defaultTimeout)
|
||||
@@ -17,15 +19,4 @@ final class Suite0_OnboardingRebuildTests: BaseUITestCase {
|
||||
createAccount.waitForLoad(timeout: defaultTimeout)
|
||||
}
|
||||
|
||||
func testR003_createAccountExpandedFormFieldsAreInteractable() throws {
|
||||
throw XCTSkip("Skeleton: implement deterministic focus assertions for username/email/password fields")
|
||||
}
|
||||
|
||||
func testR004_emailFieldCanFocusAndAcceptTyping() throws {
|
||||
throw XCTSkip("Skeleton: implement replacement for legacy email focus failure")
|
||||
}
|
||||
|
||||
func testR005_createAccountContinueOnlyAfterValidInputs() throws {
|
||||
throw XCTSkip("Skeleton: validate disabled/enabled state transition for Create Account")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import XCTest
|
||||
|
||||
/// Rebuild plan for legacy failures in Suite1_RegistrationTests:
|
||||
/// - test07, test09, test10, test11, test12
|
||||
/// Coverage is split into smaller tests for easier isolation.
|
||||
final class Suite1_RegistrationRebuildTests: BaseUITestCase {
|
||||
override var includeResetStateLaunchArgument: Bool { false }
|
||||
|
||||
func testR101_registerFormCanOpenFromLogin() {
|
||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||
let register = TestFlows.openRegisterFromLogin(app: app)
|
||||
register.waitForLoad(timeout: defaultTimeout)
|
||||
}
|
||||
|
||||
func testR102_registerFormAcceptsValidInput() {
|
||||
UITestHelpers.ensureOnLoginScreen(app: app)
|
||||
let register = TestFlows.openRegisterFromLogin(app: app)
|
||||
XCTAssertTrue(app.textFields[UITestID.Auth.registerUsernameField].exists)
|
||||
XCTAssertTrue(app.textFields[UITestID.Auth.registerEmailField].exists)
|
||||
XCTAssertTrue(app.secureTextFields[UITestID.Auth.registerPasswordField].exists)
|
||||
XCTAssertTrue(app.secureTextFields[UITestID.Auth.registerConfirmPasswordField].exists)
|
||||
XCTAssertTrue(app.buttons[UITestID.Auth.registerButton].exists)
|
||||
}
|
||||
|
||||
func testR103_successfulRegistrationTransitionsToVerificationGate() throws {
|
||||
throw XCTSkip("Skeleton: submit valid registration and assert verification gate")
|
||||
}
|
||||
|
||||
func testR104_verificationGateBlocksMainAppBeforeCodeEntry() throws {
|
||||
throw XCTSkip("Skeleton: assert no tab bar access while unverified")
|
||||
}
|
||||
|
||||
func testR105_validVerificationCodeTransitionsToMainApp() throws {
|
||||
throw XCTSkip("Skeleton: use deterministic verification code fixture and assert main app root")
|
||||
}
|
||||
|
||||
func testR106_mainAppSessionAfterVerificationCanReachProfile() throws {
|
||||
throw XCTSkip("Skeleton: assert verified user can navigate tab bar and profile")
|
||||
}
|
||||
|
||||
func testR107_invalidVerificationCodeShowsErrorAndStaysBlocked() throws {
|
||||
throw XCTSkip("Skeleton: replacement for legacy test09")
|
||||
}
|
||||
|
||||
func testR108_incompleteVerificationCodeDoesNotCompleteVerification() throws {
|
||||
throw XCTSkip("Skeleton: replacement for legacy test10")
|
||||
}
|
||||
|
||||
func testR109_verifyButtonDisabledForIncompleteCode() throws {
|
||||
throw XCTSkip("Skeleton: optional split from legacy test10 button state assertion")
|
||||
}
|
||||
|
||||
func testR110_relaunchUnverifiedUserNeverLandsInMainApp() throws {
|
||||
throw XCTSkip("Skeleton: replacement for legacy test11")
|
||||
}
|
||||
|
||||
func testR111_relaunchUnverifiedUserResumesVerificationOrLoginGate() throws {
|
||||
throw XCTSkip("Skeleton: acceptable states after relaunch")
|
||||
}
|
||||
|
||||
func testR112_logoutFromVerificationReturnsToLogin() throws {
|
||||
throw XCTSkip("Skeleton: replacement for legacy test12")
|
||||
}
|
||||
|
||||
func testR113_verificationElementsDisappearAfterLogout() throws {
|
||||
throw XCTSkip("Skeleton: split assertion from legacy test12")
|
||||
}
|
||||
|
||||
func testR114_logoutFromVerifiedMainAppReturnsToLogin() throws {
|
||||
throw XCTSkip("Skeleton: split assertion from legacy test07 cleanup")
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import XCTest
|
||||
/// - test06_logout
|
||||
final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
override var includeResetStateLaunchArgument: Bool { false }
|
||||
override var relaunchBetweenTests: Bool { true }
|
||||
private let validUser = RebuildTestUserFactory.seeded
|
||||
|
||||
private enum AuthLandingState {
|
||||
@@ -13,6 +14,8 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
}
|
||||
|
||||
override func setUpWithError() throws {
|
||||
// Force a clean app launch so no stale field text persists between tests
|
||||
app.terminate()
|
||||
try super.setUpWithError()
|
||||
UITestHelpers.ensureLoggedOut(app: app)
|
||||
}
|
||||
@@ -34,7 +37,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
loginFromLoginScreen(user: user)
|
||||
|
||||
let mainRoot = app.otherElements[UITestID.Root.mainTabs]
|
||||
if mainRoot.waitForExistence(timeout: longTimeout) || app.tabBars.firstMatch.waitForExistence(timeout: 2) {
|
||||
if mainRoot.waitForExistence(timeout: loginTimeout) || app.tabBars.firstMatch.waitForExistence(timeout: 2) {
|
||||
return .main
|
||||
}
|
||||
|
||||
@@ -85,9 +88,9 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
let landing = loginAndWaitForAuthenticatedLanding(user: validUser)
|
||||
switch landing {
|
||||
case .main:
|
||||
RebuildSessionAssertions.assertOnMainApp(app, timeout: longTimeout)
|
||||
RebuildSessionAssertions.assertOnMainApp(app, timeout: loginTimeout)
|
||||
case .verification:
|
||||
RebuildSessionAssertions.assertOnVerification(app, timeout: longTimeout)
|
||||
RebuildSessionAssertions.assertOnVerification(app, timeout: loginTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
|
||||
switch landing {
|
||||
case .main:
|
||||
RebuildSessionAssertions.assertOnMainApp(app, timeout: longTimeout)
|
||||
RebuildSessionAssertions.assertOnMainApp(app, timeout: loginTimeout)
|
||||
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
if tabBar.waitForExistence(timeout: 5) {
|
||||
@@ -127,7 +130,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
case .verification:
|
||||
logoutFromVerificationIfNeeded()
|
||||
}
|
||||
RebuildSessionAssertions.assertOnLogin(app, timeout: longTimeout)
|
||||
RebuildSessionAssertions.assertOnLogin(app, timeout: loginTimeout)
|
||||
}
|
||||
|
||||
func testR206_postLogoutMainAppIsNoLongerAccessible() {
|
||||
@@ -139,7 +142,7 @@ final class Suite2_AuthenticationRebuildTests: BaseUITestCase {
|
||||
case .verification:
|
||||
logoutFromVerificationIfNeeded()
|
||||
}
|
||||
RebuildSessionAssertions.assertOnLogin(app, timeout: longTimeout)
|
||||
RebuildSessionAssertions.assertOnLogin(app, timeout: loginTimeout)
|
||||
|
||||
XCTAssertFalse(app.otherElements[UITestID.Root.mainTabs].exists, "Main app root should not be visible after logout")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ import XCTest
|
||||
/// - test06_viewResidenceDetails
|
||||
final class Suite3_ResidenceRebuildTests: BaseUITestCase {
|
||||
override var includeResetStateLaunchArgument: Bool { false }
|
||||
override var relaunchBetweenTests: Bool { true }
|
||||
override func setUpWithError() throws {
|
||||
// Force a clean app launch so no stale field text persists between tests
|
||||
app.terminate()
|
||||
try super.setUpWithError()
|
||||
UITestHelpers.ensureLoggedOut(app: app)
|
||||
}
|
||||
@@ -23,8 +26,27 @@ final class Suite3_ResidenceRebuildTests: BaseUITestCase {
|
||||
login.enterPassword("TestPass123!")
|
||||
app.buttons[AccessibilityIdentifiers.Authentication.loginButton].waitForExistenceOrFail(timeout: defaultTimeout).forceTap()
|
||||
|
||||
// Wait for either main tabs or verification screen
|
||||
let main = MainTabScreenObject(app: app)
|
||||
main.waitForLoad(timeout: longTimeout)
|
||||
let mainTabs = app.otherElements[UITestID.Root.mainTabs]
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
let verificationScreen = VerificationScreen(app: app)
|
||||
|
||||
let deadline = Date().addingTimeInterval(loginTimeout)
|
||||
while Date() < deadline {
|
||||
if mainTabs.exists || tabBar.exists {
|
||||
break
|
||||
}
|
||||
if verificationScreen.codeField.exists {
|
||||
verificationScreen.enterCode(TestAccountAPIClient.debugVerificationCode)
|
||||
verificationScreen.submitCode()
|
||||
_ = mainTabs.waitForExistence(timeout: loginTimeout) || tabBar.waitForExistence(timeout: 5)
|
||||
break
|
||||
}
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.5))
|
||||
}
|
||||
|
||||
XCTAssertTrue(mainTabs.exists || tabBar.exists, "Expected main app root to appear after login (with verification handling)")
|
||||
main.goToResidences()
|
||||
}
|
||||
|
||||
@@ -89,14 +111,14 @@ final class Suite3_ResidenceRebuildTests: BaseUITestCase {
|
||||
let name = "UITest Home \(Int(Date().timeIntervalSince1970))"
|
||||
_ = createResidence(name: name)
|
||||
let created = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] %@", name)).firstMatch
|
||||
XCTAssertTrue(created.waitForExistence(timeout: longTimeout), "Created residence should appear in list")
|
||||
XCTAssertTrue(created.waitForExistence(timeout: loginTimeout), "Created residence should appear in list")
|
||||
}
|
||||
|
||||
func testR307_newResidenceAppearsInResidenceList() throws {
|
||||
let name = "UITest Verify \(Int(Date().timeIntervalSince1970))"
|
||||
_ = createResidence(name: name)
|
||||
let created = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] %@", name)).firstMatch
|
||||
XCTAssertTrue(created.waitForExistence(timeout: longTimeout), "New residence should be visible in residences list")
|
||||
XCTAssertTrue(created.waitForExistence(timeout: loginTimeout), "New residence should be visible in residences list")
|
||||
}
|
||||
|
||||
func testR308_openResidenceDetailsFromResidenceList() throws {
|
||||
@@ -104,7 +126,7 @@ final class Suite3_ResidenceRebuildTests: BaseUITestCase {
|
||||
_ = createResidence(name: name)
|
||||
|
||||
let row = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] %@", name)).firstMatch
|
||||
row.waitForExistenceOrFail(timeout: longTimeout).forceTap()
|
||||
row.waitForExistenceOrFail(timeout: loginTimeout).forceTap()
|
||||
|
||||
let edit = app.buttons[AccessibilityIdentifiers.Residence.editButton]
|
||||
let delete = app.buttons[AccessibilityIdentifiers.Residence.deleteButton]
|
||||
|
||||
Reference in New Issue
Block a user