Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SF50 TOLD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@
repositoryURL = "https://github.com/RISCfuture/XCUITestKit";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.2.1;
minimumVersion = 1.4.0;
};
};
0163BCA72DDEF40D008FEE8F /* XCRemoteSwiftPackageReference "SwiftNASR" */ = {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions SF50 TOLDUITests/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/AboutPage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import XCUITestKit

final class AboutPage: BasePage {

Expand All @@ -25,6 +26,6 @@ final class AboutPage: BasePage {
scrollAttempts += 1
}
}
return disclaimer.waitForExistence(timeout: 2)
return disclaimer.wait(timeout: 2)
}
}
12 changes: 6 additions & 6 deletions SF50 TOLDUITests/Pages/AirportPickerPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -62,7 +62,7 @@ final class AirportPickerPage: BasePage {
} else {
app.swipeUp()
}
if searchField.waitForExistence(timeout: 3) { return }
if searchField.wait(timeout: 3) { return }
}
}

Expand All @@ -71,15 +71,15 @@ 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"
)
}

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)
Expand Down
5 changes: 3 additions & 2 deletions SF50 TOLDUITests/Pages/BasePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -103,6 +103,7 @@ class BasePage {
for _ in 0..<attempts {
if element.isSelected { return }
forceTap(element)
if element.isSelected { return }
_ = XCTWaiter().wait(
for: [
XCTNSPredicateExpectation(
Expand Down
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/ClimbPage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import XCUITestKit

final class ClimbPage: BasePage {

Expand All @@ -22,7 +23,7 @@ final class ClimbPage: BasePage {
// MARK: - Actions

func adjustFuel(to normalizedPosition: CGFloat) {
XCTAssertTrue(fuelSlider.waitForExistence(timeout: 2), "Fuel slider should exist")
XCTAssertTrue(fuelSlider.wait(timeout: 2), "Fuel slider should exist")
fuelSlider.adjust(toNormalizedSliderPosition: normalizedPosition)
}

Expand Down
5 changes: 3 additions & 2 deletions SF50 TOLDUITests/Pages/ClimbProfilePage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import XCUITestKit

final class ClimbProfilePage: ProfilePage {

Expand All @@ -9,7 +10,7 @@ final class ClimbProfilePage: ProfilePage {
guard openWeatherMenu("weatherLayerPicker") else { return }

let option = app.buttons[layer].firstMatch
XCTAssertTrue(option.waitForExistence(timeout: 5), "“\(layer)” should be offered")
XCTAssertTrue(option.wait(timeout: 5), "“\(layer)” should be offered")
forceTap(option)
}

Expand All @@ -19,7 +20,7 @@ final class ClimbProfilePage: ProfilePage {

let segment = isOn ? "On" : "Off"
let option = app.buttons[segment].firstMatch
XCTAssertTrue(option.waitForExistence(timeout: 5), "“\(segment)” should be offered")
XCTAssertTrue(option.wait(timeout: 5), "“\(segment)” should be offered")
forceTap(option)
}
}
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/GoAroundProfilePage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import XCUITestKit

final class GoAroundProfilePage: ProfilePage {

Expand All @@ -8,7 +9,7 @@ final class GoAroundProfilePage: ProfilePage {
/// goes dead rather than opening onto options none of which can be picked.
func isWeatherPillEnabled(timeout: TimeInterval = 10) -> 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
}
Expand Down
4 changes: 2 additions & 2 deletions SF50 TOLDUITests/Pages/LoadingConsentPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions SF50 TOLDUITests/Pages/NOTAMPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -26,15 +26,15 @@ 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)
}

func setObstacleDistance(_ value: String) {
XCTAssertTrue(
obstacleDistanceField.waitForExistence(timeout: 2),
obstacleDistanceField.wait(timeout: 2),
"Obstacle distance field should exist"
)
obstacleDistanceField.enter(value, app: app)
Expand All @@ -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,
Expand All @@ -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)
}
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/ProfilePage.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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.
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.
Expand Down
5 changes: 3 additions & 2 deletions SF50 TOLDUITests/Pages/ReportViewerPage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import XCUITestKit

final class ReportViewerPage: BasePage {

Expand All @@ -10,15 +11,15 @@ 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.
///
/// 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() {
Expand Down
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/RunwayMapPage.swift
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion SF50 TOLDUITests/Pages/RunwayPickerPage.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import XCTest
import XCUITestKit

final class RunwayPickerPage: BasePage {

func selectRunway(_ runway: String) {
let row = app.buttons["runwayRow-\(runway)"].firstMatch
XCTAssertTrue(

Check failure on line 8 in SF50 TOLDUITests/Pages/RunwayPickerPage.swift

View workflow job for this annotation

GitHub Actions / ci / UI Tests (iPhone 17 Pro, iOS latest)

testAirportRecentsTab, XCTAssertTrue failed - Runway 28R should appear
row.waitForExistence(timeout: 2),
row.wait(timeout: 2),
"Runway \(runway) should appear"
)
forceTap(row)
Expand Down
2 changes: 1 addition & 1 deletion SF50 TOLDUITests/Pages/ScenarioDetailPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ final class ScenarioDetailPage: BasePage {
func goBack() {
dismissKeyboard()
tapBackButton()
_ = app.navigationBars["Scenarios"].waitForExistence(timeout: 3)
_ = app.navigationBars["Scenarios"].wait(timeout: 3)
}
}
23 changes: 17 additions & 6 deletions SF50 TOLDUITests/Pages/ScenariosSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand All @@ -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"]

Expand All @@ -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)
})
}
}

Expand Down
Loading
Loading