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>
71 lines
2.5 KiB
Swift
71 lines
2.5 KiB
Swift
//
|
|
// NoteEditorScreen.swift
|
|
// Tests iOS
|
|
//
|
|
// Screen object for the Journal Note editor sheet.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
struct NoteEditorScreen {
|
|
let app: XCUIApplication
|
|
|
|
private let defaultTimeout: TimeInterval = 2
|
|
private let navigationTimeout: TimeInterval = 5
|
|
|
|
// MARK: - Elements
|
|
|
|
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
|
|
|
|
@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
|
|
}
|
|
|
|
@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: defaultTimeout) {
|
|
selectAll.tap()
|
|
}
|
|
textEditor.typeText(text)
|
|
return self
|
|
}
|
|
|
|
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(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
|
|
|
|
@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 = #filePath, line: UInt = #line) {
|
|
textEditor.waitForNonExistence(timeout: navigationTimeout, message: "Note editor should be dismissed", file: file, line: line)
|
|
}
|
|
}
|