Stabilize flaky UI wizard and settings test flows

This commit is contained in:
treyt
2026-02-18 14:51:04 -06:00
parent 7e54ff2ef2
commit 7eaa21abd4
2 changed files with 114 additions and 19 deletions

View File

@@ -118,25 +118,40 @@ extension XCUIElement {
file: StaticString = #filePath,
line: UInt = #line
) -> XCUIElement {
var scrollsRemaining = maxScrolls
while !exists || !isHittable {
guard scrollsRemaining > 0 else {
XCTFail("Could not scroll \(self) into view after \(maxScrolls) scrolls",
file: file, line: line)
return self
if exists && isHittable { return self }
func attemptScroll(_ scrollDirection: ScrollDirection, attempts: Int) -> Bool {
var remaining = attempts
while (!exists || !isHittable) && remaining > 0 {
switch scrollDirection {
case .down:
scrollView.swipeUp(velocity: .slow)
case .up:
scrollView.swipeDown(velocity: .slow)
}
remaining -= 1
}
switch direction {
case .down:
scrollView.swipeUp(velocity: .slow)
case .up:
scrollView.swipeDown(velocity: .slow)
}
scrollsRemaining -= 1
return exists && isHittable
}
if attemptScroll(direction, attempts: maxScrolls) {
return self
}
let reverseDirection: ScrollDirection = direction == .down ? .up : .down
if attemptScroll(reverseDirection, attempts: maxScrolls) {
return self
}
XCTFail(
"Could not scroll \(self) into view after \(maxScrolls) scrolls in either direction",
file: file,
line: line
)
return self
}
}
enum ScrollDirection {
enum ScrollDirection: Equatable {
case up, down
}