import XCTest /// Task management tests /// Uses UITestHelpers for consistent login/logout behavior /// IMPORTANT: Tasks require at least one residence to exist /// /// 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 final class Suite5_TaskTests: AuthenticatedTestCase { override var useSeededAccount: Bool { true } override func setUpWithError() throws { try super.setUpWithError() navigateToTasks() } override func tearDownWithError() throws { try super.tearDownWithError() } // MARK: - Helper Methods /// Finds the Add Task button using multiple strategies /// The button exists in two places: /// 1. Toolbar (always visible when residences exist) /// 2. Empty state (visible when no tasks exist) private func findAddTaskButton() -> XCUIElement { sleep(2) // Wait for screen to fully render // Strategy 1: Try accessibility identifier let addButtonById = app.buttons[AccessibilityIdentifiers.Task.addButton].firstMatch if addButtonById.exists && addButtonById.isEnabled { return addButtonById } // Strategy 2: Look for toolbar add button (navigation bar plus button) let navBarButtons = app.navigationBars.buttons for i in 0..