Stabilize iOS UI test foundation and fix flaky suites
This commit is contained in:
@@ -32,10 +32,7 @@ class BaseUITestCase: XCTestCase {
|
||||
super.setUp()
|
||||
continueAfterFailure = false
|
||||
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = buildLaunchArguments()
|
||||
app.launchEnvironment = buildLaunchEnvironment()
|
||||
app.launch()
|
||||
app = launchApp(resetState: true)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
@@ -48,8 +45,11 @@ class BaseUITestCase: XCTestCase {
|
||||
|
||||
// MARK: - Launch Configuration
|
||||
|
||||
private func buildLaunchArguments() -> [String] {
|
||||
var args = ["--ui-testing", "--reset-state", "--disable-animations"]
|
||||
private func buildLaunchArguments(resetState: Bool) -> [String] {
|
||||
var args = ["--ui-testing", "--disable-animations", "-AppleLanguages", "(en)", "-AppleLocale", "en_US"]
|
||||
if resetState {
|
||||
args.append("--reset-state")
|
||||
}
|
||||
if bypassSubscription {
|
||||
args.append("--bypass-subscription")
|
||||
}
|
||||
@@ -78,4 +78,29 @@ class BaseUITestCase: XCTestCase {
|
||||
screenshot.lifetime = .keepAlways
|
||||
add(screenshot)
|
||||
}
|
||||
|
||||
// MARK: - Shared Test Utilities
|
||||
|
||||
@discardableResult
|
||||
func launchApp(resetState: Bool) -> XCUIApplication {
|
||||
let application = XCUIApplication()
|
||||
application.launchArguments = buildLaunchArguments(resetState: resetState)
|
||||
application.launchEnvironment = buildLaunchEnvironment()
|
||||
application.launch()
|
||||
return application
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func relaunchPreservingState() -> XCUIApplication {
|
||||
app.terminate()
|
||||
let relaunched = launchApp(resetState: false)
|
||||
app = relaunched
|
||||
return relaunched
|
||||
}
|
||||
|
||||
func assertDayContentVisible(timeout: TimeInterval = 8, file: StaticString = #file, line: UInt = #line) {
|
||||
let hasEntry = app.firstEntryRow.waitForExistence(timeout: timeout)
|
||||
let hasMoodHeader = app.element(UITestID.Day.moodHeader).waitForExistence(timeout: 2)
|
||||
XCTAssertTrue(hasEntry || hasMoodHeader, "Day view should show entry list or mood header", file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user