Skip to content

Commit 7e612cb

Browse files
committed
Configurable splash delay and test updates
Allow the splash screen exit delay to be overridden via a launch argument for UI tests. Adds a defaultExitDelay constant and a configuredExitDelay(arguments:) helper that reads "-ui-testing-splash-delay" from ProcessInfo.arguments. Also sets an accessibilityIdentifier on the SplashScreenView so tests can reliably query it. Updates CoverageRuntimeUITests to pass the new launch argument, wait for the splash view and title with extended timeouts, and assert the main tab bar appears.
1 parent 5cfe98a commit 7e612cb

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

CycleOne/Views/Shared/SplashScreenView.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct SplashScreenView: View {
2020
@State private var ringOpacity: Double
2121
@State private var exitOffset: CGFloat
2222

23+
private static let defaultExitDelay: TimeInterval = 2.2
24+
2325
init(onFinish: @escaping () -> Void) {
2426
self.onFinish = onFinish
2527
_logoScale = State(initialValue: 0.5)
@@ -34,6 +36,20 @@ struct SplashScreenView: View {
3436
_exitOffset = State(initialValue: 0)
3537
}
3638

39+
private static func configuredExitDelay(
40+
arguments: [String] = ProcessInfo.processInfo.arguments
41+
) -> TimeInterval {
42+
guard let index = arguments.firstIndex(of: "-ui-testing-splash-delay"),
43+
arguments.indices.contains(index + 1),
44+
let delay = TimeInterval(arguments[index + 1]),
45+
delay >= 0
46+
else {
47+
return defaultExitDelay
48+
}
49+
50+
return delay
51+
}
52+
3753
var body: some View {
3854
ZStack {
3955
Color(.systemBackground)
@@ -142,7 +158,7 @@ struct SplashScreenView: View {
142158

143159
// Exit sequence
144160
DispatchQueue.main.asyncAfter(
145-
deadline: .now() + 2.2
161+
deadline: .now() + Self.configuredExitDelay()
146162
) {
147163
// Ring burst
148164
withAnimation(
@@ -172,6 +188,7 @@ struct SplashScreenView: View {
172188
}
173189
}
174190
}
191+
.accessibilityIdentifier("SplashScreenView")
175192
}
176193
}
177194

CycleOneUITests/Tests/CoverageRuntimeUITests.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ final class CoverageRuntimeUITests: XCTestCase {
1111
skipOnboarding: true,
1212
clearData: true,
1313
seedInsights: false,
14-
skipSplash: false
14+
skipSplash: false,
15+
extraLaunchArguments: ["-ui-testing-splash-delay", "6"]
1516
)
1617

17-
XCTAssertTrue(app.staticTexts["CycleOne"].waitForExistence(timeout: 4))
18-
XCTAssertTrue(app.staticTexts["Privacy-first period tracking"].exists)
18+
let splashRoot = UITestAppHarness.element(
19+
withIdentifier: "SplashScreenView",
20+
in: app
21+
)
22+
let splashTitle = app.staticTexts["CycleOne"]
1923

20-
UITestAppHarness.waitForMainTabs(in: app)
24+
XCTAssertTrue(splashRoot.waitForExistence(timeout: 12))
25+
XCTAssertTrue(splashTitle.waitForExistence(timeout: 12))
26+
27+
XCTAssertTrue(app.tabBars.firstMatch.waitForExistence(timeout: 25))
2128
}
2229

2330
@MainActor

0 commit comments

Comments
 (0)