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 @@
// MonthViewInteractionTests.swift
// Tests iOS
//
// Month view interaction tests tapping into month content.
// Month view interaction tests -- tapping and scrolling content.
//
import XCTest
@@ -10,79 +10,41 @@ import XCTest
final class MonthViewInteractionTests: BaseUITestCase {
override var seedFixture: String? { "week_of_moods" }
/// TC-030: Tap on month view content and verify interaction works without crash.
/// TC-030: Tap on month grid and verify the app remains stable.
func testMonthView_TapContent_NoCrash() {
let tabBar = TabBarScreen(app: app)
// 1. Navigate to Month tab
tabBar.tapMonth()
XCTAssertTrue(tabBar.monthTab.isSelected, "Month tab should be selected")
// 2. Wait for month grid content to load
let monthGrid = app.element(UITestID.Month.grid)
let scrollView = app.scrollViews.firstMatch
// Either the month_grid identifier or a scroll view should be present
let contentLoaded = monthGrid.waitForExistence(timeout: 5) ||
scrollView.waitForExistence(timeout: 5)
XCTAssertTrue(contentLoaded, "Month view should have loaded content")
captureScreenshot(name: "month_view_before_tap")
// 3. Tap on the month view content (first cell/card in the grid)
// Try the month_grid element first; fall back to tapping the scroll view content
if monthGrid.exists && monthGrid.isHittable {
monthGrid.tap()
} else if scrollView.exists && scrollView.isHittable {
// Tap near the center of the scroll view to hit a month card
scrollView.tap()
}
// 4. Verify the app did not crash the tab bar should still be accessible
XCTAssertTrue(
tabBar.monthTab.waitForExistence(timeout: 5),
"App should remain stable after tapping month content"
monthGrid.waitUntilHittableOrFail(
timeout: navigationTimeout,
message: "Month grid should be hittable"
)
// 5. Check if any detail/navigation occurred (look for navigation bar or content change)
// Month view may show a detail view or popover depending on the card tapped
let navBar = app.navigationBars.firstMatch
let detailAppeared = navBar.waitForExistence(timeout: 3)
monthGrid.forceTap()
if detailAppeared {
captureScreenshot(name: "month_detail_view")
} else {
// No navigation occurred, which is also valid the main check is no crash
captureScreenshot(name: "month_view_after_tap")
}
// Verify the tab bar is still present (app did not crash)
tabBar.assertVisible()
captureScreenshot(name: "month_view_after_tap")
}
/// Navigate to Month tab with data, scroll down, and verify no crash.
/// Navigate to Month tab with data, scroll down/up, and verify no crash.
func testMonthView_Scroll_NoCrash() {
let tabBar = TabBarScreen(app: app)
// Navigate to Month tab
tabBar.tapMonth()
XCTAssertTrue(tabBar.monthTab.isSelected, "Month tab should be selected")
// Wait for content to load
let scrollView = app.scrollViews.firstMatch
guard scrollView.waitForExistence(timeout: 5) else {
// If no scroll view, the month view may use a different layout verify no crash
XCTAssertTrue(tabBar.monthTab.exists, "App should not crash on month view")
return
}
// Scroll down and up
scrollView.swipeUp()
scrollView.swipeDown()
// Verify the app is still stable
XCTAssertTrue(
tabBar.monthTab.waitForExistence(timeout: 3),
"App should remain stable after scrolling month view"
let monthGrid = app.element(UITestID.Month.grid)
monthGrid.waitForExistenceOrFail(
timeout: navigationTimeout,
message: "Month grid should be visible for scrolling"
)
app.swipeUp()
app.swipeDown()
tabBar.assertVisible()
captureScreenshot(name: "month_view_after_scroll")
}
}