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:
@@ -11,49 +11,36 @@ final class SettingsActionTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "week_of_moods" }
|
||||
override var bypassSubscription: Bool { true }
|
||||
|
||||
/// TC-063 / TC-160: Navigate to Settings, clear all data, verify entries are gone.
|
||||
/// TC-063 / TC-160: Navigate to Settings, clear all data, verify app remains usable.
|
||||
func testClearData_RemovesAllEntries() {
|
||||
// First verify we have data
|
||||
let entryRow = app.firstEntryRow
|
||||
XCTAssertTrue(
|
||||
entryRow.waitForExistence(timeout: 5),
|
||||
"Entry rows should exist before clearing"
|
||||
)
|
||||
// Verify we have data before clearing
|
||||
let dayScreen = DayScreen(app: app)
|
||||
dayScreen.assertAnyEntryExists()
|
||||
|
||||
// Navigate to Settings tab
|
||||
// Navigate to Settings > Settings sub-tab
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
let settingsScreen = tabBar.tapSettings()
|
||||
settingsScreen.assertVisible()
|
||||
|
||||
// Switch to Settings sub-tab (not Customize)
|
||||
settingsScreen.tapSettingsTab()
|
||||
|
||||
// Scroll down to find Clear All Data (it's in the DEBUG section at the bottom)
|
||||
guard settingsScreen.clearDataButton.waitForExistence(timeout: 2) ||
|
||||
app.swipeUntilExists(settingsScreen.clearDataButton, direction: .up, maxSwipes: 6) else {
|
||||
// In non-DEBUG builds, clear data might not be visible
|
||||
// Skip test gracefully
|
||||
return
|
||||
}
|
||||
|
||||
// Scroll to and tap Clear All Data
|
||||
settingsScreen.clearDataButton
|
||||
.scrollIntoView(in: app.scrollViews.firstMatch, direction: .up)
|
||||
settingsScreen.tapClearData()
|
||||
|
||||
// Give SwiftData time to propagate the deletion before navigating
|
||||
_ = app.waitForExistence(timeout: 2.0)
|
||||
|
||||
// Navigate back to Day tab
|
||||
tabBar.tapDay()
|
||||
|
||||
// App should remain usable after clearing data.
|
||||
// After a full clear, Day view may show mood header, entry rows, or empty state.
|
||||
let hasEntry = app.firstEntryRow.waitForExistence(timeout: 10)
|
||||
let hasMoodHeader = app.element(UITestID.Day.moodHeader).waitForExistence(timeout: 2)
|
||||
let hasEmptyState = app.element(UITestID.Day.emptyStateNoData).waitForExistence(timeout: 2)
|
||||
XCTAssertTrue(hasEntry || hasMoodHeader || hasEmptyState,
|
||||
"Day view should show entries, mood header, or empty state after clearing data")
|
||||
// App should remain usable: mood header, entries, or empty state visible
|
||||
let moodHeader = app.element(UITestID.Day.moodHeader)
|
||||
let emptyState = app.element(UITestID.Day.emptyStateNoData)
|
||||
let entryRow = app.firstEntryRow
|
||||
|
||||
// Clear action should not crash the app.
|
||||
XCTAssertTrue(app.tabBars.firstMatch.exists, "App should remain responsive after clearing data")
|
||||
let anyVisible = moodHeader.waitForExistence(timeout: navigationTimeout)
|
||||
|| emptyState.waitForExistence(timeout: defaultTimeout)
|
||||
|| entryRow.waitForExistence(timeout: defaultTimeout)
|
||||
|
||||
XCTAssertTrue(anyVisible, "Day view should show mood header, entries, or empty state after clearing data")
|
||||
|
||||
captureScreenshot(name: "data_cleared")
|
||||
}
|
||||
@@ -63,19 +50,11 @@ final class SettingsActionTests: BaseUITestCase {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
let settingsScreen = tabBar.tapSettings()
|
||||
settingsScreen.assertVisible()
|
||||
|
||||
// Switch to Settings sub-tab
|
||||
settingsScreen.tapSettingsTab()
|
||||
|
||||
// Find the analytics toggle
|
||||
guard settingsScreen.analyticsToggle.waitForExistence(timeout: 2) ||
|
||||
app.swipeUntilExists(settingsScreen.analyticsToggle, direction: .up, maxSwipes: 6) else {
|
||||
// Toggle may not be visible depending on scroll position
|
||||
captureScreenshot(name: "analytics_toggle_not_found")
|
||||
return
|
||||
}
|
||||
|
||||
// Tap the toggle
|
||||
// Scroll to analytics toggle and tap it
|
||||
settingsScreen.analyticsToggle
|
||||
.scrollIntoView(in: app.scrollViews.firstMatch, direction: .up)
|
||||
settingsScreen.tapAnalyticsToggle()
|
||||
|
||||
captureScreenshot(name: "analytics_toggled")
|
||||
|
||||
Reference in New Issue
Block a user