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:
@@ -2,7 +2,7 @@
|
||||
// StabilityTests.swift
|
||||
// Tests iOS
|
||||
//
|
||||
// Full navigation stability tests — visit every screen without crash.
|
||||
// Full navigation stability tests -- visit every screen without crash.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@@ -10,67 +10,56 @@ import XCTest
|
||||
final class StabilityTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "week_of_moods" }
|
||||
|
||||
/// TC-152: Navigate to every screen and feature without crashing.
|
||||
func testFullNavigation_NoCrash() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
|
||||
// 1. Day tab (default) - verify loaded
|
||||
assertTabSelected(tabBar.dayTab, name: "Day (initial)")
|
||||
captureScreenshot(name: "stability_day")
|
||||
|
||||
// 2. Open entry detail
|
||||
/// TC-152a: Open entry detail sheet and dismiss without crash.
|
||||
func testStability_EntryDetail() {
|
||||
let firstEntry = app.firstEntryRow
|
||||
if firstEntry.waitForExistence(timeout: 5) {
|
||||
firstEntry.tapWhenReady()
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
if detailScreen.sheet.waitForExistence(timeout: 3) {
|
||||
captureScreenshot(name: "stability_entry_detail")
|
||||
detailScreen.dismiss()
|
||||
detailScreen.assertDismissed()
|
||||
}
|
||||
}
|
||||
firstEntry.waitForExistenceOrFail(timeout: navigationTimeout, message: "Entry row should exist from seeded data")
|
||||
firstEntry.forceTap()
|
||||
|
||||
// 3. Month tab
|
||||
tabBar.tapMonth()
|
||||
assertTabSelected(tabBar.monthTab, name: "Month")
|
||||
captureScreenshot(name: "stability_month")
|
||||
|
||||
// 4. Year tab
|
||||
tabBar.tapYear()
|
||||
assertTabSelected(tabBar.yearTab, name: "Year")
|
||||
captureScreenshot(name: "stability_year")
|
||||
|
||||
// 5. Insights tab
|
||||
tabBar.tapInsights()
|
||||
assertTabSelected(tabBar.insightsTab, name: "Insights")
|
||||
captureScreenshot(name: "stability_insights")
|
||||
|
||||
// 6. Settings tab - Customize sub-tab
|
||||
tabBar.tapSettings()
|
||||
assertTabSelected(tabBar.settingsTab, name: "Settings")
|
||||
captureScreenshot(name: "stability_settings_customize")
|
||||
|
||||
// 7. Settings tab - Settings sub-tab
|
||||
let settingsScreen = SettingsScreen(app: app)
|
||||
settingsScreen.tapSettingsTab()
|
||||
captureScreenshot(name: "stability_settings_settings")
|
||||
|
||||
// 8. Back to Customize sub-tab
|
||||
settingsScreen.tapCustomizeTab()
|
||||
captureScreenshot(name: "stability_settings_customize_return")
|
||||
|
||||
// 9. Back to Day
|
||||
tabBar.tapDay()
|
||||
assertTabSelected(tabBar.dayTab, name: "Day")
|
||||
|
||||
captureScreenshot(name: "stability_full_navigation_complete")
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
detailScreen.dismiss()
|
||||
detailScreen.assertDismissed()
|
||||
}
|
||||
|
||||
/// Wait for a tab to become selected (iOS 26 Liquid Glass may delay state updates).
|
||||
private func assertTabSelected(_ tab: XCUIElement, name: String, timeout: TimeInterval = 8) {
|
||||
let predicate = NSPredicate(format: "isSelected == true")
|
||||
let expectation = XCTNSPredicateExpectation(predicate: predicate, object: tab)
|
||||
let result = XCTWaiter.wait(for: [expectation], timeout: timeout)
|
||||
XCTAssertEqual(result, .completed, "\(name) tab should be selected")
|
||||
/// TC-152b: Navigate to Month tab without crash.
|
||||
func testStability_MonthTab() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapMonth()
|
||||
let monthGrid = app.element(UITestID.Month.grid)
|
||||
monthGrid.waitForExistenceOrFail(timeout: navigationTimeout, message: "Month grid should be visible")
|
||||
}
|
||||
|
||||
/// TC-152c: Navigate to Year tab without crash.
|
||||
func testStability_YearTab() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapYear()
|
||||
let heatmap = app.element(UITestID.Year.heatmap)
|
||||
heatmap.waitForExistenceOrFail(timeout: navigationTimeout, message: "Year heatmap should be visible")
|
||||
}
|
||||
|
||||
/// TC-152d: Navigate to Insights tab without crash.
|
||||
func testStability_InsightsTab() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapInsights()
|
||||
let insightsHeader = app.element(UITestID.Insights.header)
|
||||
insightsHeader.waitForExistenceOrFail(timeout: navigationTimeout, message: "Insights header should be visible")
|
||||
}
|
||||
|
||||
/// TC-152e: Navigate to Settings and switch sub-tabs without crash.
|
||||
func testStability_SettingsTabs() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
let settingsScreen = tabBar.tapSettings()
|
||||
settingsScreen.assertVisible()
|
||||
settingsScreen.tapSettingsTab()
|
||||
settingsScreen.tapCustomizeTab()
|
||||
}
|
||||
|
||||
/// TC-152f: Full round-trip back to Day tab without crash.
|
||||
func testStability_ReturnToDay() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapSettings()
|
||||
let dayScreen = tabBar.tapDay()
|
||||
dayScreen.assertAnyEntryExists()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user