Harden test harness and UI suite

This commit is contained in:
Trey t
2026-04-03 15:30:54 -05:00
parent 87b9971714
commit 0fa3db5401
13 changed files with 319 additions and 55 deletions

View File

@@ -59,6 +59,33 @@ class BaseUITestCase: XCTestCase {
screenshot.lifetime = .keepAlways
add(screenshot)
}
/// Polls until the condition becomes true or the timeout expires.
@discardableResult
func waitUntil(
timeout: TimeInterval = BaseUITestCase.defaultTimeout,
pollInterval: TimeInterval = 0.2,
_ message: String? = nil,
file: StaticString = #filePath,
line: UInt = #line,
condition: @escaping () -> Bool
) -> Bool {
let deadline = Date().addingTimeInterval(timeout)
while Date() < deadline {
if condition() {
return true
}
let remaining = deadline.timeIntervalSinceNow
let interval = min(pollInterval, max(0.01, remaining))
RunLoop.current.run(until: Date().addingTimeInterval(interval))
}
let success = condition()
XCTAssertTrue(success, message ?? "Condition was not met within \(timeout)s", file: file, line: line)
return success
}
}
// MARK: - Wait Helpers