Files
OpenAppLock/OpenAppLockUITests/UITestSupport.swift
Brendan Chen e91d8344a9 refactor: rename app from Severed to OpenAppLock
Full rename ahead of App Store submission: project, targets, bundle
identifiers (dev.bchen.Severed -> dev.bchen.OpenAppLock), entitlements
file, app entry point, user-facing onboarding strings, test helpers,
and docs. Verified: all 62 unit tests pass.
2026-06-12 18:05:06 -04:00

49 lines
1.5 KiB
Swift

//
// UITestSupport.swift
// OpenAppLockUITests
//
import XCTest
extension XCUIApplication {
/// Launches the app in UI-testing mode: in-memory storage, mocked Screen
/// Time authorization, and no shield side effects.
static func launchOpenAppLock(
onboardingCompleted: Bool = true,
seedScenario: String? = nil
) -> XCUIApplication {
let app = XCUIApplication()
var arguments = ["-ui-testing"]
arguments.append(onboardingCompleted ? "-onboarding-completed" : "-onboarding-required")
if let seedScenario {
arguments.append("-seed-scenario=\(seedScenario)")
}
app.launchArguments = arguments
app.launch()
return app
}
}
extension XCUIApplication {
/// Finds an element by accessibility identifier regardless of how SwiftUI
/// exposes it (Other, StaticText, Button, ).
func element(_ identifier: String) -> XCUIElement {
descendants(matching: .any).matching(identifier: identifier).firstMatch
}
}
extension XCUIElement {
/// Asserts the element appears within the timeout, then returns it.
@discardableResult
func waitToAppear(
timeout: TimeInterval = 5, file: StaticString = #filePath, line: UInt = #line
) -> XCUIElement {
XCTAssertTrue(
waitForExistence(timeout: timeout),
"Expected \(self) to exist within \(timeout)s",
file: file, line: line
)
return self
}
}