mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:02:10 +00:00
Automatic Accessibility Audits on previews part 1 (#4322)
* setup target * accessibility tests implementation * removed ipad check * pr improvements * updated project
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2022-2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
enum Application {
|
||||
static func launch(viewID: String) -> XCUIApplication {
|
||||
checkEnvironments()
|
||||
|
||||
let app = XCUIApplication()
|
||||
|
||||
let launchEnvironment = [
|
||||
"ACCESSIBILITY_VIEW": viewID
|
||||
]
|
||||
|
||||
app.launchEnvironment = launchEnvironment
|
||||
app.launch()
|
||||
return app
|
||||
}
|
||||
|
||||
private static func checkEnvironments() {
|
||||
let requirediPhoneSimulator = "iPhone17,3" // iPhone 16
|
||||
let requiredOSVersion = 18
|
||||
|
||||
let osVersion = ProcessInfo().operatingSystemVersion
|
||||
guard osVersion.majorVersion == requiredOSVersion else {
|
||||
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
|
||||
}
|
||||
|
||||
guard let deviceModel = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] else {
|
||||
fatalError("Unknown simulator.")
|
||||
}
|
||||
guard deviceModel == requirediPhoneSimulator else {
|
||||
fatalError("Running on \(deviceModel) but we only support \(requirediPhoneSimulator)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright 2025 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class Test: XCTestCase {
|
||||
var app: XCUIApplication!
|
||||
|
||||
func test() async throws {
|
||||
let client = try UITestsSignalling.Client(mode: .tests)
|
||||
app = Application.launch(viewID: "SecureBackupLogoutConfirmationScreen_Previews")
|
||||
await client.waitForApp()
|
||||
defer { try? client.stop() }
|
||||
|
||||
try client.send(.accessibilityAudit(.nextPreview))
|
||||
forLoop: for await signal in client.signals.values {
|
||||
switch signal {
|
||||
case .accessibilityAudit(let auditSignal):
|
||||
switch auditSignal {
|
||||
case .nextPreviewReady(let name):
|
||||
try? app.performAccessibilityAudit { issue in
|
||||
XCTFail("\(name): \(issue)")
|
||||
return true
|
||||
}
|
||||
try? client.send(.accessibilityAudit(.nextPreview))
|
||||
case .noMorePreviews:
|
||||
break forLoop
|
||||
default:
|
||||
fatalError("Unhandled signal")
|
||||
}
|
||||
default:
|
||||
fatalError("Unhandled signal")
|
||||
}
|
||||
}
|
||||
|
||||
app.terminate()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user