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:
@@ -22,28 +22,27 @@ final class AppThemeTests: BaseUITestCase {
|
||||
|
||||
/// TC-070: Open Browse Themes sheet and verify all 12 theme cards exist.
|
||||
func testBrowseThemes_AllCardsExist() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
let settingsScreen = tabBar.tapSettings()
|
||||
let settingsScreen = TabBarScreen(app: app).tapSettings()
|
||||
settingsScreen.assertVisible()
|
||||
settingsScreen.tapCustomizeTab()
|
||||
|
||||
let customizeScreen = CustomizeScreen(app: app)
|
||||
XCTAssertTrue(customizeScreen.openThemePicker(), "Themes sheet should appear with theme cards")
|
||||
customizeScreen.openThemePicker()
|
||||
|
||||
// Verify all 12 theme cards are accessible (some may require scrolling)
|
||||
for theme in allThemes {
|
||||
let card = customizeScreen.appThemeCard(named: theme)
|
||||
if !card.exists { _ = app.swipeUntilExists(card, direction: .up, maxSwipes: 6) }
|
||||
XCTAssertTrue(
|
||||
card.waitForExistence(timeout: 3),
|
||||
"Theme card '\(theme)' should exist in the Browse Themes sheet"
|
||||
card.scrollIntoView(in: app, direction: .up)
|
||||
card.waitForExistenceOrFail(
|
||||
timeout: defaultTimeout,
|
||||
message: "Theme card '\(theme)' should exist in the Browse Themes sheet"
|
||||
)
|
||||
}
|
||||
|
||||
captureScreenshot(name: "browse_themes_all_cards")
|
||||
}
|
||||
|
||||
/// TC-070: Apply a representative set of themes and verify no crash.
|
||||
/// TC-070: Apply a theme and verify no crash.
|
||||
func testApplyThemes_NoCrash() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
let settingsScreen = tabBar.tapSettings()
|
||||
@@ -51,52 +50,26 @@ final class AppThemeTests: BaseUITestCase {
|
||||
settingsScreen.tapCustomizeTab()
|
||||
|
||||
let customizeScreen = CustomizeScreen(app: app)
|
||||
XCTAssertTrue(customizeScreen.openThemePicker(), "Browse Themes sheet should open")
|
||||
customizeScreen.openThemePicker()
|
||||
|
||||
// Tap a representative sample of themes: first, middle, last
|
||||
let sampled = ["Zen Garden", "Heartfelt", "Journal"]
|
||||
for theme in sampled {
|
||||
let card = customizeScreen.appThemeCard(named: theme)
|
||||
if !card.exists { _ = app.swipeUntilExists(card, direction: .up, maxSwipes: 6) }
|
||||
if card.waitForExistence(timeout: 3) {
|
||||
card.tapWhenReady(timeout: 3)
|
||||
// Tap a theme card, apply it
|
||||
let card = customizeScreen.appThemeCard(named: "Zen Garden")
|
||||
card.scrollIntoView(in: app, direction: .up)
|
||||
card.forceTap()
|
||||
|
||||
// Apply theme via stable accessibility id.
|
||||
let applyButton = app.element(UITestID.Customize.previewApplyButton)
|
||||
if applyButton.waitForExistence(timeout: 3) {
|
||||
applyButton.tapWhenReady()
|
||||
} else {
|
||||
let cancelButton = app.element(UITestID.Customize.previewCancelButton)
|
||||
if cancelButton.waitForExistence(timeout: 2) {
|
||||
cancelButton.tapWhenReady()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Apply via the preview apply button
|
||||
let applyButton = app.element(UITestID.Customize.previewApplyButton)
|
||||
applyButton.waitForExistenceOrFail(timeout: navigationTimeout, message: "Apply button should appear after tapping theme card")
|
||||
applyButton.forceTap()
|
||||
|
||||
captureScreenshot(name: "themes_applied")
|
||||
|
||||
// Dismiss the themes sheet by swiping down or tapping Done
|
||||
// Dismiss the themes sheet
|
||||
let doneButton = app.element(UITestID.Customize.pickerDoneButton)
|
||||
if doneButton.waitForExistence(timeout: 2) {
|
||||
doneButton.tapWhenReady()
|
||||
} else {
|
||||
// Swipe down to dismiss the sheet
|
||||
app.swipeDown()
|
||||
}
|
||||
doneButton.waitForExistenceOrFail(timeout: navigationTimeout, message: "Done button should be visible to dismiss theme picker")
|
||||
doneButton.forceTap()
|
||||
|
||||
// Wait for sheet dismissal — verify the sheet is actually gone
|
||||
// by checking that the tab bar is accessible again
|
||||
let tabBarElement = app.tabBars.firstMatch
|
||||
if !tabBarElement.waitForExistence(timeout: 3) {
|
||||
// Sheet may still be visible — try dismissing again
|
||||
app.swipeDown()
|
||||
_ = tabBarElement.waitForExistence(timeout: 3)
|
||||
}
|
||||
|
||||
// Navigate to Day tab and verify no crash — entry row should still exist
|
||||
// Navigate to Day tab and verify no crash
|
||||
tabBar.tapDay()
|
||||
assertDayContentVisible(timeout: 10)
|
||||
DayScreen(app: app).assertAnyEntryExists()
|
||||
|
||||
captureScreenshot(name: "day_view_after_theme_change")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user