diff --git a/SF50 TOLD.xcodeproj/project.pbxproj b/SF50 TOLD.xcodeproj/project.pbxproj index dda35a3..7b000a3 100644 --- a/SF50 TOLD.xcodeproj/project.pbxproj +++ b/SF50 TOLD.xcodeproj/project.pbxproj @@ -1785,7 +1785,7 @@ repositoryURL = "https://github.com/RISCfuture/XCUITestKit"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.2.1; + minimumVersion = 1.4.0; }; }; 0163BCA72DDEF40D008FEE8F /* XCRemoteSwiftPackageReference "SwiftNASR" */ = { diff --git a/SF50 TOLD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/SF50 TOLD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 88cdf17..de0df96 100644 --- a/SF50 TOLD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/SF50 TOLD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "34525bd496e974f1f173fd2f03d89eb1f4677c4d879519301a43be7a961cf383", + "originHash" : "cf98271bac939b61067fa3453d43546d77706c481f1b1f90e353b7f43ed376e7", "pins" : [ { "identity" : "buildablemacro", @@ -258,8 +258,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/RISCfuture/XCUITestKit", "state" : { - "revision" : "f0845b227dde33207bdfa0d892d059bdfddb2fb1", - "version" : "1.2.1" + "revision" : "caf3e879ff9bb34e8351b1f90c66b232ebc48083", + "version" : "1.4.0" } }, { diff --git a/SF50 TOLDUITests/Extensions.swift b/SF50 TOLDUITests/Extensions.swift index 5f53ea9..1cca400 100644 --- a/SF50 TOLDUITests/Extensions.swift +++ b/SF50 TOLDUITests/Extensions.swift @@ -41,10 +41,9 @@ extension XCUIElement { /// Waits for this element to become first responder, so that typing into it lands here rather /// than failing in a window with no keyboard focus. func waitForKeyboardFocus(timeout: TimeInterval = 5) -> Bool { - let focused = XCTNSPredicateExpectation( - predicate: NSPredicate(format: "hasKeyboardFocus == true"), - object: self - ) + let hasFocus = NSPredicate(format: "hasKeyboardFocus == true") + if hasFocus.evaluate(with: self) { return true } + let focused = XCTNSPredicateExpectation(predicate: hasFocus, object: self) return XCTWaiter().wait(for: [focused], timeout: ScaledTimeouts.scaled(timeout)) == .completed } } diff --git a/SF50 TOLDUITests/Pages/AboutPage.swift b/SF50 TOLDUITests/Pages/AboutPage.swift index ac25833..36abbe8 100644 --- a/SF50 TOLDUITests/Pages/AboutPage.swift +++ b/SF50 TOLDUITests/Pages/AboutPage.swift @@ -1,4 +1,5 @@ import XCTest +import XCUITestKit final class AboutPage: BasePage { @@ -25,6 +26,6 @@ final class AboutPage: BasePage { scrollAttempts += 1 } } - return disclaimer.waitForExistence(timeout: 2) + return disclaimer.wait(timeout: 2) } } diff --git a/SF50 TOLDUITests/Pages/AirportPickerPage.swift b/SF50 TOLDUITests/Pages/AirportPickerPage.swift index d5833a0..54db6b1 100644 --- a/SF50 TOLDUITests/Pages/AirportPickerPage.swift +++ b/SF50 TOLDUITests/Pages/AirportPickerPage.swift @@ -20,7 +20,7 @@ final class AirportPickerPage: BasePage { /// dismissing overlay, so a single `forceTap` can silently leave the previous /// segment showing — and consumers read the list instantly afterward. private func selectSegment(_ name: String) { - XCTAssertTrue(segmentedControl.waitForExistence(timeout: 5), "Airport picker should appear") + XCTAssertTrue(segmentedControl.wait(timeout: 5), "Airport picker should appear") let button = segmentedControl.buttons[name] ensureHittable(button) tapUntilSelected(button) @@ -36,7 +36,7 @@ final class AirportPickerPage: BasePage { // Tap the search field and wait for keyboard to gain focus for _ in 0..<3 { forceTap(searchField) - if app.keyboards.firstMatch.waitForExistence(timeout: 2) { break } + if app.keyboards.firstMatch.wait(timeout: 2) { break } } searchField.typeText(query) @@ -49,7 +49,7 @@ final class AirportPickerPage: BasePage { /// navigation-bar search button that must be tapped to expand into the field. private func revealSearchField() { let searchField = app.searchFields.firstMatch - if searchField.waitForExistence(timeout: 5) { return } + if searchField.wait(timeout: 5) { return } // Retry to absorb the slow Liquid Glass nav-bar settle under full-suite // load, during which the collapsed search button is briefly unhittable. @@ -62,7 +62,7 @@ final class AirportPickerPage: BasePage { } else { app.swipeUp() } - if searchField.waitForExistence(timeout: 3) { return } + if searchField.wait(timeout: 3) { return } } } @@ -71,7 +71,7 @@ final class AirportPickerPage: BasePage { let clearButton = app.searchFields.firstMatch.buttons["Clear text"] if clearButton.exists { forceTap(clearButton) } XCTAssertTrue( - segmentedControl.waitForExistence(timeout: 5), + segmentedControl.wait(timeout: 5), "Airport lists should return once the search is cleared" ) } @@ -79,7 +79,7 @@ final class AirportPickerPage: BasePage { func selectAirport(_ identifier: String) { let row = app.buttons["airportRow-\(identifier)"].firstMatch XCTAssertTrue( - row.waitForExistence(timeout: 3), + row.wait(timeout: 3), "\(identifier) should appear in results" ) forceTap(row) diff --git a/SF50 TOLDUITests/Pages/BasePage.swift b/SF50 TOLDUITests/Pages/BasePage.swift index ae86240..8074615 100644 --- a/SF50 TOLDUITests/Pages/BasePage.swift +++ b/SF50 TOLDUITests/Pages/BasePage.swift @@ -39,7 +39,7 @@ class BasePage { @discardableResult func scrollToElement(_ element: XCUIElement) -> XCUIElement? { // If already visible, return immediately - if element.waitForExistence(timeout: 5) && element.isVisible { + if element.wait(timeout: 5) && element.isVisible { ensureHittable(element) return element } @@ -61,7 +61,7 @@ class BasePage { // side of the current position is reached. for direction in [(from: 0.8, to: 0.2), (from: 0.2, to: 0.8)] { for _ in 0..<12 { - if element.waitForExistence(timeout: 0.3) && element.isVisible { + if element.exists && element.isVisible { ensureHittable(element) return element } @@ -103,6 +103,7 @@ class BasePage { for _ in 0.. Bool { let pill = app.descendants(matching: .any)["weatherLayerPicker"].firstMatch - guard pill.waitForExistence(timeout: timeout) else { + guard pill.wait(timeout: timeout) else { XCTFail("The weather pill was not found") return false } diff --git a/SF50 TOLDUITests/Pages/LoadingConsentPage.swift b/SF50 TOLDUITests/Pages/LoadingConsentPage.swift index 8ff8fce..14da8b9 100644 --- a/SF50 TOLDUITests/Pages/LoadingConsentPage.swift +++ b/SF50 TOLDUITests/Pages/LoadingConsentPage.swift @@ -7,11 +7,11 @@ final class LoadingConsentPage: BasePage { var deferButton: XCUIElement { app.buttons["deferDataButton"] } func isDisplayed() -> Bool { - downloadButton.waitForExistence(timeout: 5) + downloadButton.wait(timeout: 5) } func deferUntilLater() -> TabBarPage { - XCTAssertTrue(deferButton.waitForExistence(timeout: 5), "Defer button should exist") + XCTAssertTrue(deferButton.wait(timeout: 5), "Defer button should exist") tapAndEnsureNavigation( element: deferButton, expectedElement: app.textFields["payloadField"].firstMatch diff --git a/SF50 TOLDUITests/Pages/NOTAMPage.swift b/SF50 TOLDUITests/Pages/NOTAMPage.swift index c050ac2..52af82f 100644 --- a/SF50 TOLDUITests/Pages/NOTAMPage.swift +++ b/SF50 TOLDUITests/Pages/NOTAMPage.swift @@ -17,7 +17,7 @@ final class NOTAMPage: BasePage { // MARK: - Runway Shortening func setRunwayShortening(_ value: String) { - XCTAssertTrue(distanceField.waitForExistence(timeout: 2), "Distance field should exist") + XCTAssertTrue(distanceField.wait(timeout: 2), "Distance field should exist") distanceField.enter(value, app: app) dismissKeyboard() } @@ -26,7 +26,7 @@ final class NOTAMPage: BasePage { func setObstacleHeight(_ value: String) { XCTAssertTrue( - obstacleHeightField.waitForExistence(timeout: 2), + obstacleHeightField.wait(timeout: 2), "Obstacle height field should exist" ) obstacleHeightField.enter(value, app: app) @@ -34,7 +34,7 @@ final class NOTAMPage: BasePage { func setObstacleDistance(_ value: String) { XCTAssertTrue( - obstacleDistanceField.waitForExistence(timeout: 2), + obstacleDistanceField.wait(timeout: 2), "Obstacle distance field should exist" ) obstacleDistanceField.enter(value, app: app) @@ -43,7 +43,7 @@ final class NOTAMPage: BasePage { // MARK: - Contamination (Landing) func selectContamination(_ type: String) { - if contaminationTypePicker.waitForExistence(timeout: 2) { + if contaminationTypePicker.wait(timeout: 2) { ensureHittable(contaminationTypePicker) let option = app.buttons[type] // Opening the picker is a single tap that iPad/Liquid Glass can drop, @@ -61,7 +61,7 @@ final class NOTAMPage: BasePage { } func adjustContaminationDepth(to normalizedPosition: CGFloat) { - if contaminationDepthSlider.waitForExistence(timeout: 2) { + if contaminationDepthSlider.wait(timeout: 2) { contaminationDepthSlider.adjust(toNormalizedSliderPosition: normalizedPosition) } } @@ -71,7 +71,7 @@ final class NOTAMPage: BasePage { /// Fills the editor in from the first downloaded NOTAM that can fill it. func fillFromFirstProposal() { XCTAssertTrue( - fillFromNOTAMButton.waitForExistence(timeout: 5), + fillFromNOTAMButton.wait(timeout: 5), "A downloaded NOTAM should offer to fill the editor in" ) ensureHittable(fillFromNOTAMButton) @@ -82,7 +82,7 @@ final class NOTAMPage: BasePage { func clearAllNOTAMs() { let clearButton = app.buttons["clearNOTAMsButton"] - XCTAssertTrue(clearButton.waitForExistence(timeout: 2), "Clear NOTAMs button should exist") + XCTAssertTrue(clearButton.wait(timeout: 2), "Clear NOTAMs button should exist") ensureHittable(clearButton) forceTap(clearButton) } diff --git a/SF50 TOLDUITests/Pages/ProfilePage.swift b/SF50 TOLDUITests/Pages/ProfilePage.swift index cfa7345..24b9455 100644 --- a/SF50 TOLDUITests/Pages/ProfilePage.swift +++ b/SF50 TOLDUITests/Pages/ProfilePage.swift @@ -1,4 +1,5 @@ import XCTest +import XCUITestKit /// What the climb and go-around profile screens share: the same chart, plotted from the same /// pipeline, behind the same weather controls. @@ -6,7 +7,7 @@ class ProfilePage: BasePage { func isChartVisible(timeout: TimeInterval = 30) -> Bool { let chart = app.descendants(matching: .any)["terrainProfileChart"] - return chart.waitForExistence(timeout: timeout) + return chart.wait(timeout: timeout) } /// Opens one of the chart's weather pull-downs. diff --git a/SF50 TOLDUITests/Pages/ReportViewerPage.swift b/SF50 TOLDUITests/Pages/ReportViewerPage.swift index 32d6072..d2af510 100644 --- a/SF50 TOLDUITests/Pages/ReportViewerPage.swift +++ b/SF50 TOLDUITests/Pages/ReportViewerPage.swift @@ -1,4 +1,5 @@ import XCTest +import XCUITestKit final class ReportViewerPage: BasePage { @@ -10,7 +11,7 @@ final class ReportViewerPage: BasePage { } func isDisplayed() -> Bool { - app.navigationBars[title].waitForExistence(timeout: 10) + app.navigationBars[title].wait(timeout: 10) } /// Whether the report itself rendered, rather than just the sheet around it. @@ -18,7 +19,7 @@ final class ReportViewerPage: BasePage { /// The navigation bar appears whether or not the web view drew anything, so this looks for a /// heading from inside the document. func showsReportContent() -> Bool { - app.webViews.staticTexts["Available Runways"].waitForExistence(timeout: 15) + app.webViews.staticTexts["Available Runways"].wait(timeout: 15) } func dismiss() { diff --git a/SF50 TOLDUITests/Pages/RunwayMapPage.swift b/SF50 TOLDUITests/Pages/RunwayMapPage.swift index d9e01dd..8c7810c 100644 --- a/SF50 TOLDUITests/Pages/RunwayMapPage.swift +++ b/SF50 TOLDUITests/Pages/RunwayMapPage.swift @@ -1,9 +1,10 @@ import XCTest +import XCUITestKit final class RunwayMapPage: BasePage { func isDisplayed(runway: String) -> Bool { - app.navigationBars["Runway \(runway)"].waitForExistence(timeout: 5) + app.navigationBars["Runway \(runway)"].wait(timeout: 5) } func goBack() { diff --git a/SF50 TOLDUITests/Pages/RunwayPickerPage.swift b/SF50 TOLDUITests/Pages/RunwayPickerPage.swift index 3a343e6..02c4961 100644 --- a/SF50 TOLDUITests/Pages/RunwayPickerPage.swift +++ b/SF50 TOLDUITests/Pages/RunwayPickerPage.swift @@ -1,11 +1,12 @@ import XCTest +import XCUITestKit final class RunwayPickerPage: BasePage { func selectRunway(_ runway: String) { let row = app.buttons["runwayRow-\(runway)"].firstMatch XCTAssertTrue( - row.waitForExistence(timeout: 2), + row.wait(timeout: 2), "Runway \(runway) should appear" ) forceTap(row) diff --git a/SF50 TOLDUITests/Pages/ScenarioDetailPage.swift b/SF50 TOLDUITests/Pages/ScenarioDetailPage.swift index ec96562..66eaee9 100644 --- a/SF50 TOLDUITests/Pages/ScenarioDetailPage.swift +++ b/SF50 TOLDUITests/Pages/ScenarioDetailPage.swift @@ -74,6 +74,6 @@ final class ScenarioDetailPage: BasePage { func goBack() { dismissKeyboard() tapBackButton() - _ = app.navigationBars["Scenarios"].waitForExistence(timeout: 3) + _ = app.navigationBars["Scenarios"].wait(timeout: 3) } } diff --git a/SF50 TOLDUITests/Pages/ScenariosSettingsPage.swift b/SF50 TOLDUITests/Pages/ScenariosSettingsPage.swift index d5f0bfc..6b06a97 100644 --- a/SF50 TOLDUITests/Pages/ScenariosSettingsPage.swift +++ b/SF50 TOLDUITests/Pages/ScenariosSettingsPage.swift @@ -23,7 +23,7 @@ final class ScenariosSettingsPage: BasePage { addButton = app.buttons["Add Scenario"].firstMatch } XCTAssertTrue( - addButton.waitForExistence(timeout: 2), + addButton.wait(timeout: 2), "Add Scenario button should exist" ) tapAndEnsureNavigation( @@ -37,11 +37,11 @@ final class ScenariosSettingsPage: BasePage { let text = app.staticTexts[name] // Wait briefly for data to render after restore - if text.waitForExistence(timeout: 3) { return true } + if text.wait(timeout: 3) { return true } // Scroll to top before searching downward app.scrollToTop() - if text.waitForExistence(timeout: 1) { return true } + if text.wait(timeout: 1) { return true } var findAttempts = 0 while !text.exists && findAttempts < 10 { @@ -51,6 +51,15 @@ final class ScenariosSettingsPage: BasePage { return text.exists } + /// Whether the scenario's row has left the list, allowing for one still on its way out. + /// + /// For a row that was on screen, as one just deleted is: a row that stays keeps its place in the + /// hierarchy, so there is no list to search. + func scenarioIsGone(_ name: String) -> Bool { + let text = app.staticTexts[name] + return !text.exists || text.waitForNonExistence(timeout: 3) + } + func deleteScenario(_ name: String) async { let deleteButton = app.buttons["Delete"] @@ -63,14 +72,16 @@ final class ScenariosSettingsPage: BasePage { let cell = app.cells.containing(.staticText, identifier: name).firstMatch let target = cell.exists ? cell : text target.swipeLeft(velocity: .fast) - if deleteButton.waitForExistence(timeout: 1) { break } + if deleteButton.wait(timeout: 1) { break } } - if deleteButton.waitForExistence(timeout: 2) { + if deleteButton.wait(timeout: 2) { // The Delete button (and any confirmation) disappears once the tap // registers; a single forceTap is intermittently dropped on iPad, so // retry until it's gone. - await deleteButton.tap(until: { deleteButton.waitForNonExistence(timeout: 2) }) + await deleteButton.tap(until: { + !deleteButton.exists || deleteButton.waitForNonExistence(timeout: 2) + }) } } diff --git a/SF50 TOLDUITests/Pages/SettingsPage.swift b/SF50 TOLDUITests/Pages/SettingsPage.swift index 8ecf685..7c6c286 100644 --- a/SF50 TOLDUITests/Pages/SettingsPage.swift +++ b/SF50 TOLDUITests/Pages/SettingsPage.swift @@ -20,13 +20,17 @@ final class SettingsPage: BasePage { } var useDefaultFactorsButton: XCUIElement { app.buttons["useDefaultFactorsButton"] } var isThrustScheduleToggleVisible: Bool { - thrustScheduleToggle.waitForExistence(timeout: 1) + thrustScheduleToggle.wait(timeout: 1) + } + /// Whether the thrust schedule toggle is gone, allowing for one still on its way out. + var isThrustScheduleToggleHidden: Bool { + !thrustScheduleToggle.exists || thrustScheduleToggle.waitForNonExistence(timeout: 1) } // MARK: - Actions func selectAircraftModel(_ model: String) { - XCTAssertTrue(aircraftTypePicker.waitForExistence(timeout: 2), "Aircraft picker should exist") + XCTAssertTrue(aircraftTypePicker.wait(timeout: 2), "Aircraft picker should exist") ensureHittable(aircraftTypePicker) let option = app.buttons[model] // Opening the picker is a single tap that iPad/Liquid Glass can drop; @@ -40,13 +44,13 @@ final class SettingsPage: BasePage { } func setEmptyWeight(_ weight: String) { - XCTAssertTrue(weightField.waitForExistence(timeout: 2), "Weight field should exist") + XCTAssertTrue(weightField.wait(timeout: 2), "Weight field should exist") weightField.enter(weight, app: app) } func setSafetyFactorDry(_ value: String) { XCTAssertTrue( - safetyFactorDryField.waitForExistence(timeout: 2), + safetyFactorDryField.wait(timeout: 2), "Safety factor dry field should exist" ) safetyFactorDryField.enter(value, app: app) @@ -64,7 +68,7 @@ final class SettingsPage: BasePage { for _ in 0..<4 { if menuItem.exists || button.exists || popUpButton.exists { break } forceTap(toggle!) - _ = menuItem.waitForExistence(timeout: 1) + _ = menuItem.wait(timeout: 1) } let option = [menuItem, button, popUpButton].first(where: \.exists) XCTAssertNotNil( @@ -77,7 +81,7 @@ final class SettingsPage: BasePage { func selectTimeZone(_ zone: String) { revealTimeZonePicker() XCTAssertTrue( - timeZoneDisplayPicker.waitForExistence(timeout: 2), + timeZoneDisplayPicker.wait(timeout: 2), "Time zone picker should exist" ) ensureHittable(timeZoneDisplayPicker) @@ -103,7 +107,7 @@ final class SettingsPage: BasePage { let start = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.7)) let end = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.2)) start.press(forDuration: 0.1, thenDragTo: end) - _ = timeZoneDisplayPicker.waitForExistence(timeout: 0.6) + _ = timeZoneDisplayPicker.wait(timeout: 0.6) } } diff --git a/SF50 TOLDUITests/Pages/TerrainSettingsPage.swift b/SF50 TOLDUITests/Pages/TerrainSettingsPage.swift index 0342a7d..7e071f2 100644 --- a/SF50 TOLDUITests/Pages/TerrainSettingsPage.swift +++ b/SF50 TOLDUITests/Pages/TerrainSettingsPage.swift @@ -1,4 +1,5 @@ import XCTest +import XCUITestKit final class TerrainSettingsPage: BasePage { @@ -13,7 +14,7 @@ final class TerrainSettingsPage: BasePage { scrollAttempts += 1 } } - return totalDownloaded.waitForExistence(timeout: 2) + return totalDownloaded.wait(timeout: 2) } func goBack() { diff --git a/SF50 TOLDUITests/Pages/WeatherPickerPage.swift b/SF50 TOLDUITests/Pages/WeatherPickerPage.swift index 9604050..d77776d 100644 --- a/SF50 TOLDUITests/Pages/WeatherPickerPage.swift +++ b/SF50 TOLDUITests/Pages/WeatherPickerPage.swift @@ -20,10 +20,10 @@ final class WeatherPickerPage: BasePage { func dismissInProgressLoad() { if windDirectionField.exists { return } let cancelButton = app.buttons["cancelWeatherUpdateButton"] - if cancelButton.waitForExistence(timeout: ScaledTimeouts.scaled(3)) { + if cancelButton.wait(timeout: ScaledTimeouts.scaled(3)) { cancelButton.forceTap() } - _ = windDirectionField.waitForExistence(timeout: ScaledTimeouts.scaled(10)) + _ = windDirectionField.wait(timeout: ScaledTimeouts.scaled(10)) } func setWindDirection(_ value: String) { diff --git a/SF50 TOLDUITests/Pages/WelcomePage.swift b/SF50 TOLDUITests/Pages/WelcomePage.swift index 3891928..dd2565b 100644 --- a/SF50 TOLDUITests/Pages/WelcomePage.swift +++ b/SF50 TOLDUITests/Pages/WelcomePage.swift @@ -8,9 +8,11 @@ final class WelcomePage: BasePage { var continueButton: XCUIElement { app.buttons["continueButton"] } var thrustScheduleToggle: XCUIElement { app.switches["updatedThrustScheduleToggle"] } + /// Defers the nav-data loader if it is up. The loader and the welcome screen take each other's + /// place, so a welcome screen already showing means there is no loader to wait for. func handleDatabaseLoaderIfNeeded() { let deferButton = app.buttons["deferDataButton"] - if deferButton.waitForExistence(timeout: 2) { + if !continueButton.exists, deferButton.wait(timeout: 2) { forceTap(deferButton) } } @@ -19,25 +21,25 @@ final class WelcomePage: BasePage { func waitForReady() { XCTAssertTrue( - continueButton.waitForExistence(timeout: 5), + continueButton.wait(timeout: 5), "Welcome screen should be fully loaded" ) } func selectModel(_ model: String) { XCTAssertTrue( - modelPicker.waitForExistence(timeout: 5), + modelPicker.wait(timeout: 5), "Model picker should be accessible" ) let button = modelPicker.buttons[model] - XCTAssertTrue(button.waitForExistence(timeout: 2), "\(model) button should exist in picker") + XCTAssertTrue(button.wait(timeout: 2), "\(model) button should exist in picker") ensureHittable(button) tapUntilSelected(button) } func setEmptyWeight(_ weight: String) { XCTAssertTrue( - emptyWeightField.waitForExistence(timeout: 2), + emptyWeightField.wait(timeout: 2), "Empty weight field should be accessible" ) emptyWeightField.enter(weight, app: app) @@ -45,7 +47,7 @@ final class WelcomePage: BasePage { func toggleThrustSchedule() { XCTAssertTrue( - thrustScheduleToggle.waitForExistence(timeout: 2), + thrustScheduleToggle.wait(timeout: 2), "Thrust schedule toggle should exist" ) ensureHittable(thrustScheduleToggle) @@ -58,7 +60,7 @@ final class WelcomePage: BasePage { app.swipeDown() } XCTAssertTrue( - continueButton.waitForExistence(timeout: 5), + continueButton.wait(timeout: 5), "Continue button should be tappable" ) ensureHittable(continueButton) @@ -67,14 +69,16 @@ final class WelcomePage: BasePage { expectedElement: app.textFields["payloadField"].firstMatch ) - // If the data loader appears after setup, defer it + // If the data loader appears after setup, defer it. It takes the tab view's place, so it + // cannot be up while the payload field is. + let payloadField = app.textFields["payloadField"].firstMatch let deferButton = app.buttons["deferDataButton"] - if deferButton.waitForExistence(timeout: 3) { + if !payloadField.exists, deferButton.wait(timeout: 3) { forceTap(deferButton) } XCTAssertTrue( - app.textFields["payloadField"].firstMatch.waitForExistence(timeout: 10), + payloadField.wait(timeout: 10), "Payload field should appear after setup" ) return TabBarPage(app: app) @@ -87,7 +91,7 @@ final class WelcomePage: BasePage { app.swipeDown() } XCTAssertTrue( - continueButton.waitForExistence(timeout: 5), + continueButton.wait(timeout: 5), "Continue button should be tappable" ) ensureHittable(continueButton) diff --git a/SF50 TOLDUITests/SF50_TOLDUITests.swift b/SF50 TOLDUITests/SF50_TOLDUITests.swift index a8d909d..9a9fc66 100644 --- a/SF50 TOLDUITests/SF50_TOLDUITests.swift +++ b/SF50 TOLDUITests/SF50_TOLDUITests.swift @@ -32,7 +32,7 @@ extension SF50_TOLDUITests { // Performance computed but went offscale — still validates the navigation flow let offscale = takeoff.app.staticTexts["Offscale high"] XCTAssertTrue( - offscale.waitForExistence(timeout: 3), + offscale.wait(timeout: 3), "Ground run should have a value or show offscale" ) } @@ -75,8 +75,8 @@ extension SF50_TOLDUITests { await scenarios.deleteScenario("Hot Day Test") - XCTAssertFalse( - scenarios.scenarioExists("Hot Day Test"), + XCTAssertTrue( + scenarios.scenarioIsGone("Hot Day Test"), "Deleted scenario should not appear in list" ) } @@ -92,7 +92,7 @@ extension SF50_TOLDUITests { picker.dismissKeyboard() XCTAssertTrue( - picker.app.buttons["airportRow-SQL"].firstMatch.waitForExistence(timeout: 3), + picker.app.buttons["airportRow-SQL"].firstMatch.wait(timeout: 3), "SQL should appear in search results" ) @@ -102,7 +102,7 @@ extension SF50_TOLDUITests { let alreadyFavorited = picker.isAirportVisible("SQL") picker.search(for: "SQL") picker.dismissKeyboard() - _ = picker.app.buttons["airportRow-SQL"].firstMatch.waitForExistence(timeout: 2) + _ = picker.app.buttons["airportRow-SQL"].firstMatch.wait(timeout: 2) if alreadyFavorited { picker.toggleFavorite(for: "SQL") @@ -139,7 +139,7 @@ extension SF50_TOLDUITests { notams.adjustContaminationDepth(to: 0.25) notams.goBack() - _ = landing.app.staticTexts["landingDistanceValue"].waitForExistence(timeout: 5) + _ = landing.app.staticTexts["landingDistanceValue"].wait(timeout: 5) let contaminatedDistance = landing.landingDistanceValue if let baselineDistance, let contaminatedDistance { @@ -200,7 +200,7 @@ extension SF50_TOLDUITests { climb.adjustISADeviation(to: 0.5) XCTAssertTrue( - climb.speedValue.waitForExistence(timeout: 2), + climb.speedValue.wait(timeout: 2), "Climb speed value should be displayed" ) XCTAssertTrue(climb.rateValue.exists, "Climb rate value should be displayed") @@ -241,7 +241,7 @@ extension SF50_TOLDUITests { let profile = takeoff.openClimbProfile() XCTAssertTrue( - takeoff.app.navigationBars["Climb Profile"].waitForExistence(timeout: 5), + takeoff.app.navigationBars["Climb Profile"].wait(timeout: 5), "Climb Profile nav bar should appear" ) XCTAssertTrue(profile.isChartVisible(), "Terrain profile chart should appear") @@ -324,7 +324,7 @@ extension SF50_TOLDUITests { let profile = landing.openGoAroundProfile() XCTAssertTrue( - landing.app.navigationBars["Go-Around Profile"].waitForExistence(timeout: 5), + landing.app.navigationBars["Go-Around Profile"].wait(timeout: 5), "Go-Around Profile nav bar should appear" ) XCTAssertTrue(profile.isChartVisible(), "Terrain profile chart should appear") @@ -338,7 +338,7 @@ extension SF50_TOLDUITests { welcome.handleDatabaseLoaderIfNeeded() XCTAssertTrue( - welcome.continueButton.waitForExistence(timeout: 5), + welcome.continueButton.wait(timeout: 5), "Continue button should appear" ) @@ -353,7 +353,7 @@ extension SF50_TOLDUITests { let settings = tabBar.goToSettings() XCTAssertTrue( - settings.app.staticTexts["Settings"].waitForExistence(timeout: 2), + settings.app.staticTexts["Settings"].wait(timeout: 2), "Should be on Settings screen" ) } @@ -370,12 +370,12 @@ extension SF50_TOLDUITests { let picker = takeoff.openAirportPicker() picker.search(for: "ASE") - if takeoff.app.buttons["airportRow-ASE"].firstMatch.waitForExistence(timeout: 3) { + if takeoff.app.buttons["airportRow-ASE"].firstMatch.wait(timeout: 3) { picker.selectAirport("ASE") let runwayPicker = takeoff.openRunwayPicker() let firstRunway = takeoff.app.buttons["runwayRow-15"].firstMatch - if firstRunway.waitForExistence(timeout: 2) { + if firstRunway.wait(timeout: 2) { runwayPicker.selectRunway("15") } @@ -411,7 +411,7 @@ extension SF50_TOLDUITests { let about = tabBar.goToAbout() XCTAssertTrue( - about.app.navigationBars["About"].waitForExistence(timeout: 2), + about.app.navigationBars["About"].wait(timeout: 2), "About nav bar should appear" ) XCTAssertTrue(about.hasAircraftDescription(), "Aircraft description should be displayed") @@ -429,7 +429,7 @@ extension SF50_TOLDUITests { let adjustments = takeoff.openAdjustments() XCTAssertTrue( - takeoff.app.navigationBars["Takeoff Adjustments"].waitForExistence(timeout: 5), + takeoff.app.navigationBars["Takeoff Adjustments"].wait(timeout: 5), "Takeoff Adjustments nav bar should appear" ) XCTAssertTrue(adjustments.hasGroundRunSection()) @@ -445,7 +445,7 @@ extension SF50_TOLDUITests { let adjustments = landing.openAdjustments() XCTAssertTrue( - landing.app.navigationBars["Landing Adjustments"].waitForExistence(timeout: 5), + landing.app.navigationBars["Landing Adjustments"].wait(timeout: 5), "Landing Adjustments nav bar should appear" ) XCTAssertTrue(adjustments.hasGroundRunSection()) @@ -460,13 +460,13 @@ extension SF50_TOLDUITests { welcome.handleDatabaseLoaderIfNeeded() XCTAssertTrue( - welcome.continueButton.waitForExistence(timeout: 5), + welcome.continueButton.wait(timeout: 5), "Continue button should appear" ) welcome.selectModel("G2") XCTAssertTrue( - welcome.thrustScheduleToggle.waitForExistence(timeout: 2), + welcome.thrustScheduleToggle.wait(timeout: 2), "Updated thrust schedule toggle should appear for G2" ) welcome.toggleThrustSchedule() @@ -476,7 +476,7 @@ extension SF50_TOLDUITests { let settings = tabBar.goToSettings() XCTAssertTrue( - settings.aircraftTypePicker.waitForExistence(timeout: 2), + settings.aircraftTypePicker.wait(timeout: 2), "Aircraft type picker should be present in Settings" ) } @@ -489,15 +489,15 @@ extension SF50_TOLDUITests { for model in ["G2+", "G3"] { settings.selectAircraftModel(model) - XCTAssertFalse( - settings.isThrustScheduleToggleVisible, + XCTAssertTrue( + settings.isThrustScheduleToggleHidden, "Thrust schedule toggle should not appear for \(model)" ) } _ = tabBar.goToTakeoff() XCTAssertTrue( - tabBar.app.textFields["payloadField"].firstMatch.waitForExistence(timeout: 5), + tabBar.app.textFields["payloadField"].firstMatch.wait(timeout: 5), "Takeoff tab should render after model change" ) @@ -516,7 +516,7 @@ extension SF50_TOLDUITests { let settings = tabBar.goToSettings() let modelToggle = settings.selectModelToggle - XCTAssertTrue(modelToggle.waitForExistence(timeout: 2), "Model toggle should exist") + XCTAssertTrue(modelToggle.wait(timeout: 2), "Model toggle should exist") let lessThan100 = settings.app.staticTexts.matching( NSPredicate(format: "label CONTAINS 'less than 100 ft'") @@ -529,21 +529,21 @@ extension SF50_TOLDUITests { NSPredicate(format: "label CONTAINS 'match book values exactly'") ).firstMatch XCTAssertTrue( - matchBookValues.waitForExistence(timeout: 2), + matchBookValues.wait(timeout: 2), "Tabular description should appear" ) } else { settings.selectPerformanceModel("Regression") XCTAssertTrue( - lessThan100.waitForExistence(timeout: 2), + lessThan100.wait(timeout: 2), "Regression description should appear" ) } _ = tabBar.goToTakeoff() XCTAssertTrue( - tabBar.app.textFields["payloadField"].firstMatch.waitForExistence(timeout: 5), + tabBar.app.textFields["payloadField"].firstMatch.wait(timeout: 5), "Takeoff tab should still render after performance model change" ) } @@ -556,7 +556,7 @@ extension SF50_TOLDUITests { let terrain = settings.openTerrain() XCTAssertTrue( - terrain.app.navigationBars["Terrain Data"].waitForExistence(timeout: 2), + terrain.app.navigationBars["Terrain Data"].wait(timeout: 2), "Terrain Data nav bar should appear" ) XCTAssertTrue(terrain.isTotalDownloadedVisible(), "Total Downloaded label should exist") @@ -594,7 +594,7 @@ extension SF50_TOLDUITests { let notams = landing.openNOTAMs() notams.fillFromFirstProposal() XCTAssertTrue( - notams.fillBanner.waitForExistence(timeout: 2), + notams.fillBanner.wait(timeout: 2), "The banner should say the editor was filled in" ) XCTAssertTrue(notams.rwyCCSlider.exists, "The FICON report's RwyCC should be filled in") @@ -617,7 +617,7 @@ extension SF50_TOLDUITests { let notams = takeoff.openNOTAMs() notams.fillFromFirstProposal() XCTAssertTrue( - notams.fillBanner.waitForExistence(timeout: 2), + notams.fillBanner.wait(timeout: 2), "The banner should say the editor was filled in" ) let height = notams.obstacleHeightField.value as? String ?? "", @@ -683,7 +683,7 @@ extension SF50_TOLDUITests { picker.search(for: "1C9") XCTAssertTrue( - picker.app.buttons["airportRow-1C9"].firstMatch.waitForExistence(timeout: 3), + picker.app.buttons["airportRow-1C9"].firstMatch.wait(timeout: 3), "1C9 should appear in search results" ) @@ -691,7 +691,8 @@ extension SF50_TOLDUITests { searchField.tap(withNumberOfTaps: 3, numberOfTouches: 1) searchField.typeText("ZZZZZ") - _ = picker.app.buttons["airportRow-ZZZZZ"].waitForExistence(timeout: 2) + let staleRow = picker.app.buttons["airportRow-1C9"].firstMatch + if staleRow.exists { _ = staleRow.waitForNonExistence(timeout: 2) } XCTAssertEqual(picker.airportRowCount(), 0, "No airports should match ZZZZZ") } @@ -716,7 +717,7 @@ extension SF50_TOLDUITests { } takeoff.setPayload("1000") - _ = takeoff.app.staticTexts["takeoffDistanceValue"].waitForExistence(timeout: 5) + _ = takeoff.app.staticTexts["takeoffDistanceValue"].wait(timeout: 5) let heavierDistance = takeoff.distanceValue if let baselineDistance, let heavierDistance { @@ -765,7 +766,7 @@ extension SF50_TOLDUITests { landing.setVREFAdditive("10") - _ = landing.app.staticTexts["landingDistanceValue"].waitForExistence(timeout: 5) + _ = landing.app.staticTexts["landingDistanceValue"].wait(timeout: 5) let additiveDistance = landing.landingDistanceValue if let baselineDistance, let additiveDistance { @@ -796,7 +797,7 @@ extension SF50_TOLDUITests { picker.selectAirport("OAK") let dateSelector = takeoff.app.buttons["dateSelector"] - if dateSelector.waitForExistence(timeout: 2) { + if dateSelector.wait(timeout: 2) { XCTAssertTrue(dateSelector.exists, "Date selector should show time") } @@ -925,7 +926,7 @@ extension SF50_TOLDUITests { // Reopen and verify let detail2 = scenarios.openScenario("Persist Test") XCTAssertTrue( - detail2.nameField.waitForExistence(timeout: 2), + detail2.nameField.wait(timeout: 2), "Name field should exist" ) @@ -1131,7 +1132,7 @@ extension SF50_TOLDUITests { climb.adjustAltitude(to: 0.4) XCTAssertTrue( - climb.rateValue.waitForExistence(timeout: 2), + climb.rateValue.wait(timeout: 2), "Climb rate should be displayed" ) let baselineRate = climb.rateLabel @@ -1144,7 +1145,7 @@ extension SF50_TOLDUITests { // On some devices ice protection may push the rate offscale (losing the // identifier). Either a changed value or offscale proves performance impact. - if climb.rateValue.waitForExistence(timeout: 3) { + if climb.rateValue.wait(timeout: 3) { let iceProtectionRate = climb.waitForLabelChange( climb.rateValue, from: baselineRate, @@ -1178,7 +1179,7 @@ extension SF50_TOLDUITests { let nwsLabel = takeoff.app.staticTexts["Using downloaded weather from NWS"] _ = weather.scrollToElement(nwsLabel) XCTAssertTrue( - nwsLabel.waitForExistence(timeout: 5), + nwsLabel.wait(timeout: 5), "NWS weather source label should appear" ) @@ -1199,7 +1200,7 @@ extension SF50_TOLDUITests { NSPredicate(format: "label CONTAINS[c] 'load weather'") ).firstMatch XCTAssertTrue( - errorLabel.waitForExistence(timeout: 5), + errorLabel.wait(timeout: 5), "Weather error label should appear" ) @@ -1225,7 +1226,7 @@ extension SF50_TOLDUITests { let customLabel = takeoff.app.staticTexts["Using your custom weather"] _ = weather.scrollToElement(customLabel) XCTAssertTrue( - customLabel.waitForExistence(timeout: 5), + customLabel.wait(timeout: 5), "Custom weather label should appear" ) @@ -1287,7 +1288,7 @@ extension SF50_TOLDUITests { let tabBar = consent.deferUntilLater() let takeoff = tabBar.goToTakeoff() XCTAssertTrue( - takeoff.payloadField.waitForExistence(timeout: 5), + takeoff.payloadField.wait(timeout: 5), "Deferring the update should proceed into the app" ) }