Files
Reflect/Tests iOS/YearViewCollapseTests.swift
Trey T d97db4910e 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>
2026-03-24 17:00:30 -05:00

59 lines
1.9 KiB
Swift

//
// YearViewCollapseTests.swift
// Tests iOS
//
// TC-037: Collapse/expand year stats section.
//
import XCTest
final class YearViewCollapseTests: BaseUITestCase {
override var seedFixture: String? { "week_of_moods" }
override var bypassSubscription: Bool { true }
/// TC-037: Tapping the year card header collapses and re-expands stats.
func testYearView_CollapseExpand_StatsSection() {
let tabBar = TabBarScreen(app: app)
tabBar.tapYear()
// Stats section is visible by default
let statsSection = app.element(UITestID.Year.statsSection)
statsSection.waitForExistenceOrFail(
timeout: navigationTimeout,
message: "Year stats section should be visible initially"
)
// Find the current year's card header button
let currentYear = Calendar.current.component(.year, from: Date())
let headerButton = app.element(UITestID.Year.cardHeader(year: currentYear))
headerButton.waitUntilHittableOrFail(
timeout: navigationTimeout,
message: "Year card header for \(currentYear) should be hittable"
)
captureScreenshot(name: "year_stats_expanded")
// Tap header to collapse stats
headerButton.forceTap()
// Stats section should disappear
statsSection.waitForNonExistence(
timeout: defaultTimeout,
message: "Stats section should collapse after tapping header"
)
captureScreenshot(name: "year_stats_collapsed")
// Tap header again to expand stats
headerButton.forceTap()
// Stats section should reappear
statsSection.waitForExistenceOrFail(
timeout: defaultTimeout,
message: "Stats section should expand after tapping header again"
)
captureScreenshot(name: "year_stats_re_expanded")
}
}