fix for flaky tests caused by location sharing blocking execution on CI

This commit is contained in:
Mauro Romito
2025-07-18 17:47:23 +02:00
committed by Mauro
parent 8e2131b5ed
commit 8654e01a13
@@ -17,17 +17,8 @@ final class AccessibilityTests: XCTestCase {
await client.waitForApp() await client.waitForApp()
defer { try? client.stop() } defer { try? client.stop() }
// To handle system interrupts // To handle location sharing popup
_ = addUIInterruptionMonitor(withDescription: "Location access alert handler") { alert in allowLocationPermissions()
let alwaysAllowButton = alert.buttons["Allow While Using App"]
if alwaysAllowButton.exists {
alwaysAllowButton.tap()
return true
}
return false
}
// This interaction is needed to have the UIInterruptionMonitor work properly.
app.tap()
try client.send(.accessibilityAudit(.nextPreview)) try client.send(.accessibilityAudit(.nextPreview))
forLoop: for await signal in client.signals.values { forLoop: for await signal in client.signals.values {
@@ -50,6 +41,14 @@ final class AccessibilityTests: XCTestCase {
app.terminate() app.terminate()
} }
private func allowLocationPermissions() {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let notificationAlertAllowButton = springboard.buttons["Allow While Using App"].firstMatch
if notificationAlertAllowButton.waitForExistence(timeout: 10.0) {
notificationAlertAllowButton.tap()
}
}
private func performAccessibilityAuditForPreview(named name: String) { private func performAccessibilityAuditForPreview(named name: String) {
// Alows us to log the name of the preview that is being tested // Alows us to log the name of the preview that is being tested
XCTContext.runActivity(named: name) { _ in XCTContext.runActivity(named: name) { _ in