Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Audit About only once its window is on screen

Țugui Dragoș69032e6db776
diff --git a/PeelUITests/AccessibilityAuditTests.swift b/PeelUITests/AccessibilityAuditTests.swift
index f8378090..535b28d0 100644
--- a/PeelUITests/AccessibilityAuditTests.swift
+++ b/PeelUITests/AccessibilityAuditTests.swift
@@ -71,6 +71,7 @@ final class AccessibilityAuditTests: XCTestCase {
}
choose("About Peel", inMenu: "Peel", of: app)
+ waitUntilShown(app.windows["about"].links.firstMatch, named: "About")
audit("About", appearance: appearance, of: app)
app.typeKey("w", modifierFlags: .command)
@@ -126,6 +127,14 @@ final class AccessibilityAuditTests: XCTestCase {
return true
}
+ /// Waits until `element` is on screen and can be clicked, so a window still appearing isn't audited half drawn.
+ private func waitUntilShown(_ element: XCUIElement, named name: String) {
+ let shown = expectation(for: NSPredicate(format: "exists == true AND isHittable == true"), evaluatedWith: element)
+ if XCTWaiter.wait(for: [shown], timeout: 5) != .completed {
+ XCTFail("\(name) wasn't shown")
+ }
+ }
+
private func choose(_ item: String, inMenu menu: String, of app: XCUIApplication) {
let title = app.menuBars.menuBarItems[menu]
title.click()