import XCTest /// Comprehensive residence testing suite covering all scenarios, edge cases, and variations /// This test suite is designed to be bulletproof and catch regressions early /// /// Test Order (least to most complex): /// 1. Error/incomplete data tests /// 2. Creation tests /// 3. Edit/update tests /// 4. Delete/remove tests (none currently) /// 5. Navigation/view tests /// 6. Performance tests final class Suite4_ComprehensiveResidenceTests: AuthenticatedTestCase { override var useSeededAccount: Bool { true } // Test data tracking var createdResidenceNames: [String] = [] override func setUpWithError() throws { try super.setUpWithError() navigateToResidences() } override func tearDownWithError() throws { createdResidenceNames.removeAll() try super.tearDownWithError() } // MARK: - Helper Methods private func openResidenceForm() -> Bool { let addButton = findAddResidenceButton() guard addButton.exists && addButton.isEnabled else { return false } addButton.tap() sleep(3) // Verify form opened - prefer accessibility identifier over placeholder let nameFieldById = app.textFields[AccessibilityIdentifiers.Residence.nameField].firstMatch if nameFieldById.waitForExistence(timeout: 5) { return true } // Fallback to placeholder matching let nameFieldByPlaceholder = app.textFields.containing(NSPredicate(format: "placeholderValue CONTAINS[c] 'Name'")).firstMatch return nameFieldByPlaceholder.waitForExistence(timeout: 3) } private func findAddResidenceButton() -> XCUIElement { sleep(2) let addButtonById = app.buttons[AccessibilityIdentifiers.Residence.addButton].firstMatch if addButtonById.exists && addButtonById.isEnabled { return addButtonById } let navBarButtons = app.navigationBars.buttons for i in 0..