Rewrite all UI tests following fail-fast TEST_RULES patterns
Rewrote 60+ test files to follow honeydue-style test guidelines:
- defaultTimeout=2s, navigationTimeout=5s — fail fast, no long waits
- No coordinate taps (except onboarding paged TabView swipes)
- No sleep(), no retry loops
- No guard...else { return } silent passes — XCTFail everywhere
- All elements by accessibility ID via UITestID constants
- Screen objects for all navigation/actions/assertions
- One logical assertion per test method
Added missing accessibility identifiers to app views:
- MonthView.swift: added AccessibilityID.MonthView.grid to ScrollView
- YearView.swift: added AccessibilityID.YearView.heatmap to ScrollView
Framework rewrites:
- BaseUITestCase: added session ID, localeArguments, extraLaunchArguments
- WaitHelpers: waitForExistenceOrFail, waitUntilHittableOrFail,
waitForNonExistence, scrollIntoView, forceTap
- All 7 screen objects rewritten with fail-fast semantics
- TEST_RULES.md added with non-negotiable rules
Known remaining issues:
- OnboardingTests: paged TabView swipes unreliable on iOS 26 simulator
- SettingsLegalLinksTests: EULA/Privacy buttons too deep in DEBUG scroll
- Customization horizontal picker scrolling needs further tuning
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,83 +12,39 @@ final class OnboardingTests: BaseUITestCase {
|
||||
override var skipOnboarding: Bool { false }
|
||||
|
||||
/// TC-120: Complete the full onboarding flow.
|
||||
func testOnboarding_CompleteFlow() throws {
|
||||
func testOnboarding_CompleteFlow() {
|
||||
let onboarding = OnboardingScreen(app: app)
|
||||
XCTAssertTrue(onboarding.welcomeScreen.waitForExistence(timeout: 10), "Welcome screen should appear on first launch")
|
||||
onboarding.assertVisible()
|
||||
|
||||
captureScreenshot(name: "onboarding_welcome")
|
||||
|
||||
// Advance through onboarding to the subscription step.
|
||||
XCTAssertTrue(advanceToScreen(onboarding.subscriptionScreen), "Should reach onboarding subscription screen")
|
||||
captureScreenshot(name: "onboarding_time")
|
||||
captureScreenshot(name: "onboarding_day")
|
||||
captureScreenshot(name: "onboarding_style")
|
||||
captureScreenshot(name: "onboarding_subscription")
|
||||
try completeOnboardingOrSkip()
|
||||
onboarding.completeOnboarding()
|
||||
onboarding.assertDismissed()
|
||||
|
||||
captureScreenshot(name: "onboarding_complete")
|
||||
}
|
||||
|
||||
/// TC-121: After completing onboarding, relaunch should go directly to Day view.
|
||||
func testOnboarding_DoesNotRepeatAfterCompletion() throws {
|
||||
func testOnboarding_DoesNotRepeatAfterCompletion() {
|
||||
let onboarding = OnboardingScreen(app: app)
|
||||
onboarding.assertVisible()
|
||||
onboarding.completeOnboarding()
|
||||
onboarding.assertDismissed()
|
||||
|
||||
// First launch should show onboarding and allow completion.
|
||||
XCTAssertTrue(
|
||||
onboarding.welcomeScreen.waitForExistence(timeout: 5),
|
||||
"Onboarding should be shown on first launch"
|
||||
)
|
||||
XCTAssertTrue(advanceToScreen(onboarding.subscriptionScreen), "Should reach onboarding subscription screen")
|
||||
try completeOnboardingOrSkip()
|
||||
|
||||
// Relaunch preserving state — onboarding should not repeat.
|
||||
let freshApp = relaunchPreservingState()
|
||||
// Relaunch preserving state -- onboarding should not repeat
|
||||
relaunchPreservingState()
|
||||
|
||||
// Tab bar should appear immediately (no onboarding)
|
||||
let freshTabBar = freshApp.tabBars.firstMatch
|
||||
XCTAssertTrue(
|
||||
freshTabBar.waitForExistence(timeout: 10),
|
||||
"Tab bar should appear immediately on relaunch (no onboarding)"
|
||||
)
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.assertVisible()
|
||||
|
||||
// Welcome screen should NOT appear
|
||||
let welcomeAgain = freshApp.element(UITestID.Onboarding.welcome)
|
||||
let welcomeAgain = app.element(UITestID.Onboarding.welcome)
|
||||
XCTAssertFalse(
|
||||
welcomeAgain.waitForExistence(timeout: 2),
|
||||
welcomeAgain.waitForExistence(timeout: defaultTimeout),
|
||||
"Onboarding should not appear on second launch"
|
||||
)
|
||||
|
||||
captureScreenshot(name: "no_onboarding_on_relaunch")
|
||||
}
|
||||
|
||||
/// Swipe left with a brief wait for the page transition to settle.
|
||||
/// Uses a coordinate-based swipe for more reliable page advancement in paged TabView.
|
||||
private func swipeAndWait() {
|
||||
// Swipe near the top to avoid controls (DatePicker/ScrollView) stealing gestures.
|
||||
let start = app.coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.18))
|
||||
let end = app.coordinate(withNormalizedOffset: CGVector(dx: 0.1, dy: 0.18))
|
||||
start.press(forDuration: 0.05, thenDragTo: end)
|
||||
// Allow the paged TabView animation to settle
|
||||
_ = app.waitForExistence(timeout: 1.0)
|
||||
}
|
||||
|
||||
private func completeOnboardingOrSkip() throws {
|
||||
// Coordinate tap near the bottom center where "Maybe Later" is rendered.
|
||||
app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.92)).tap()
|
||||
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
if !tabBar.waitForExistence(timeout: 10) {
|
||||
throw XCTSkip("Onboarding completion CTA is not reliably exposed in simulator automation")
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
private func advanceToScreen(_ screen: XCUIElement, maxSwipes: Int = 8) -> Bool {
|
||||
if screen.waitForExistence(timeout: 2) { return true }
|
||||
for _ in 0..<maxSwipes {
|
||||
swipeAndWait()
|
||||
if screen.waitForExistence(timeout: 1.5) { return true }
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user