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:
Trey T
2026-03-24 17:00:30 -05:00
parent 2ef1c1ec51
commit d97db4910e
70 changed files with 1609 additions and 1874 deletions

View File

@@ -2,7 +2,7 @@
// OnboardingVotingTests.swift
// Tests iOS
//
// TC-122: Onboarding day voting Today vs Yesterday selection.
// TC-122: Onboarding day voting -- Today vs Yesterday selection.
//
import XCTest
@@ -11,69 +11,32 @@ final class OnboardingVotingTests: BaseUITestCase {
override var seedFixture: String? { "empty" }
override var skipOnboarding: Bool { false }
/// TC-122: Tapping Today and Yesterday buttons toggles the selection.
/// TC-122: Tapping Yesterday and Today buttons toggles the selection.
func testOnboarding_DayVoting_TodayAndYesterday() {
let onboarding = OnboardingScreen(app: app)
onboarding.assertVisible()
// Wait for welcome screen
XCTAssertTrue(
onboarding.welcomeScreen.waitForExistence(timeout: 10),
"Onboarding welcome screen should appear"
)
// Swipe from Welcome to the Day page
onboarding.swipeToNext()
// Swipe once: Welcome Day (Day is now page 2, before Time)
swipeToNext()
// Look for the "Which day should" title text to confirm we're on the day page
let dayTitle = app.staticTexts.matching(
NSPredicate(format: "label CONTAINS[c] 'Which day'")
).firstMatch
XCTAssertTrue(
dayTitle.waitForExistence(timeout: 5),
"Day screen title 'Which day should you rate?' should be visible"
)
captureScreenshot(name: "onboarding_day_screen")
// Tap the Yesterday card by looking for its text
let yesterdayText = app.staticTexts["Yesterday, Rate the previous day"]
let todayText = app.staticTexts["Today, Rate the current day"]
// Fallback: try the button by accessibility identifier
// Tap Yesterday via accessibility ID
let yesterdayButton = app.element(UITestID.Onboarding.dayYesterday)
let todayButton = app.element(UITestID.Onboarding.dayToday)
// Try tapping Yesterday via text label or accessibility ID
if yesterdayButton.exists {
yesterdayButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
} else if yesterdayText.exists {
yesterdayText.tap()
} else {
// Fallback: tap coordinate at roughly the "Yesterday" card position
app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.72)).tap()
}
yesterdayButton.waitUntilHittableOrFail(
timeout: navigationTimeout,
message: "Yesterday button should be hittable on the Day screen"
)
yesterdayButton.forceTap()
captureScreenshot(name: "onboarding_day_yesterday_tapped")
// Tap Today
if todayButton.exists {
todayButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
} else if todayText.exists {
todayText.tap()
} else {
app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.60)).tap()
}
// Tap Today via accessibility ID
let todayButton = app.element(UITestID.Onboarding.dayToday)
todayButton.waitUntilHittableOrFail(
timeout: defaultTimeout,
message: "Today button should be hittable on the Day screen"
)
todayButton.forceTap()
captureScreenshot(name: "onboarding_day_today_tapped")
}
// MARK: - Private
private func swipeToNext() {
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)
_ = app.waitForExistence(timeout: 1.0)
}
}