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:
Trey T
2026-03-24 17:00:30 -05:00
parent 2ef1c1ec51
commit d97db4910e
70 changed files with 1609 additions and 1874 deletions

View File

@@ -10,54 +10,61 @@ import XCTest
struct NoteEditorScreen {
let app: XCUIApplication
private let defaultTimeout: TimeInterval = 2
private let navigationTimeout: TimeInterval = 5
// MARK: - Elements
var navigationTitle: XCUIElement { app.navigationBars.firstMatch }
var textEditor: XCUIElement { app.textViews[UITestID.NoteEditor.text] }
var saveButton: XCUIElement { app.buttons[UITestID.NoteEditor.save] }
var cancelButton: XCUIElement { app.buttons[UITestID.NoteEditor.cancel] }
// MARK: - Actions
func typeNote(_ text: String) {
textEditor.tapWhenReady()
@discardableResult
func typeNote(_ text: String, file: StaticString = #filePath, line: UInt = #line) -> NoteEditorScreen {
textEditor
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Note text editor should be hittable", file: file, line: line)
.tap()
textEditor.typeText(text)
return self
}
func clearAndTypeNote(_ text: String) {
textEditor.tapWhenReady()
// Select all and replace
@discardableResult
func clearAndTypeNote(_ text: String, file: StaticString = #filePath, line: UInt = #line) -> NoteEditorScreen {
textEditor
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Note text editor should be hittable", file: file, line: line)
.tap()
textEditor.press(forDuration: 1.0)
let selectAll = app.menuItems["Select All"]
if selectAll.waitForExistence(timeout: 2) {
if selectAll.waitForExistence(timeout: defaultTimeout) {
selectAll.tap()
}
textEditor.typeText(text)
return self
}
func save() {
saveButton.tapWhenReady()
func save(file: StaticString = #filePath, line: UInt = #line) {
saveButton
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Save button should be hittable", file: file, line: line)
.forceTap(file: file, line: line)
}
func cancel() {
cancelButton.tapWhenReady()
func cancel(file: StaticString = #filePath, line: UInt = #line) {
cancelButton
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Cancel button should be hittable", file: file, line: line)
.forceTap(file: file, line: line)
}
// MARK: - Assertions
func assertVisible(file: StaticString = #file, line: UInt = #line) {
XCTAssertTrue(
textEditor.waitForExistence(timeout: 5),
"Note editor should be visible",
file: file, line: line
)
@discardableResult
func assertVisible(file: StaticString = #filePath, line: UInt = #line) -> NoteEditorScreen {
textEditor.waitForExistenceOrFail(timeout: navigationTimeout, message: "Note editor should be visible", file: file, line: line)
return self
}
func assertDismissed(file: StaticString = #file, line: UInt = #line) {
XCTAssertTrue(
textEditor.waitForDisappearance(timeout: 5),
"Note editor should be dismissed",
file: file, line: line
)
func assertDismissed(file: StaticString = #filePath, line: UInt = #line) {
textEditor.waitForNonExistence(timeout: navigationTimeout, message: "Note editor should be dismissed", file: file, line: line)
}
}