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,27 +12,22 @@ final class YearViewDisplayTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "week_of_moods" }
|
||||
override var bypassSubscription: Bool { true }
|
||||
|
||||
/// TC-035: Year View shows donut chart with mood distribution.
|
||||
/// The donut chart center displays the entry count with "days" text.
|
||||
/// TC-035: Year View shows the stats section containing the donut chart.
|
||||
func testYearView_DonutChartVisible() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapYear()
|
||||
|
||||
XCTAssertTrue(tabBar.yearTab.isSelected, "Year tab should be selected")
|
||||
|
||||
// Wait for stats section to render
|
||||
let statsSection = app.element(UITestID.Year.statsSection)
|
||||
XCTAssertTrue(
|
||||
statsSection.waitForExistence(timeout: 8),
|
||||
"Year stats section should be visible"
|
||||
statsSection.waitForExistenceOrFail(
|
||||
timeout: navigationTimeout,
|
||||
message: "Year stats section should be visible"
|
||||
)
|
||||
|
||||
// The donut chart center shows "days" — search globally since
|
||||
// SwiftUI flattens the accessibility tree under GeometryReader.
|
||||
// The donut chart center shows "days"
|
||||
let daysLabel = app.staticTexts["days"]
|
||||
XCTAssertTrue(
|
||||
daysLabel.waitForExistence(timeout: 3),
|
||||
"Donut chart should display 'days' label in center"
|
||||
daysLabel.waitForExistenceOrFail(
|
||||
timeout: defaultTimeout,
|
||||
message: "Donut chart should display 'days' label in center"
|
||||
)
|
||||
|
||||
captureScreenshot(name: "year_donut_chart")
|
||||
@@ -43,25 +38,22 @@ final class YearViewDisplayTests: BaseUITestCase {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapYear()
|
||||
|
||||
XCTAssertTrue(tabBar.yearTab.isSelected, "Year tab should be selected")
|
||||
|
||||
let statsSection = app.element(UITestID.Year.statsSection)
|
||||
XCTAssertTrue(
|
||||
statsSection.waitForExistence(timeout: 8),
|
||||
"Year stats section should be visible"
|
||||
statsSection.waitForExistenceOrFail(
|
||||
timeout: navigationTimeout,
|
||||
message: "Year stats section should be visible"
|
||||
)
|
||||
|
||||
// week_of_moods fixture: 2 great, 2 good, 1 avg, 1 bad, 1 horrible
|
||||
// Expected percentages: 28% (great, good) and 14% (avg, bad, horrible).
|
||||
// Search for any of the expected percentage labels.
|
||||
let found28 = app.staticTexts["28%"].waitForExistence(timeout: 3)
|
||||
let found14 = app.staticTexts["14%"].waitForExistence(timeout: 2)
|
||||
|
||||
captureScreenshot(name: "year_bar_chart")
|
||||
// Expected percentages: 28% or 14%
|
||||
let found28 = app.staticTexts["28%"].waitForExistence(timeout: defaultTimeout)
|
||||
let found14 = app.staticTexts["14%"].waitForExistence(timeout: defaultTimeout)
|
||||
|
||||
XCTAssertTrue(
|
||||
found28 || found14,
|
||||
"Bar chart should show at least one percentage value (28% or 14%)"
|
||||
)
|
||||
|
||||
captureScreenshot(name: "year_bar_chart")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user