Files
Reflect/Tests iOS/Screens/EntryDetailScreen.swift
Trey T d97db4910e 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>
2026-03-24 17:00:30 -05:00

65 lines
2.5 KiB
Swift

//
// EntryDetailScreen.swift
// Tests iOS
//
// Screen object for the Entry Detail sheet (edit mood, notes, delete).
//
import XCTest
struct EntryDetailScreen {
let app: XCUIApplication
private let defaultTimeout: TimeInterval = 2
private let navigationTimeout: TimeInterval = 5
// MARK: - Elements
var sheet: XCUIElement { app.element(UITestID.EntryDetail.sheet) }
var doneButton: XCUIElement { app.element(UITestID.EntryDetail.doneButton) }
var deleteButton: XCUIElement { app.element(UITestID.EntryDetail.deleteButton) }
func moodButton(for mood: MoodChoice) -> XCUIElement {
app.buttons["mood_button_\(mood.rawValue)"]
}
// MARK: - Actions
func dismiss(file: StaticString = #filePath, line: UInt = #line) {
doneButton
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Done button should be hittable", file: file, line: line)
.forceTap(file: file, line: line)
}
func selectMood(_ mood: MoodChoice, file: StaticString = #filePath, line: UInt = #line) {
moodButton(for: mood)
.waitUntilHittableOrFail(timeout: defaultTimeout, message: "Mood button '\(mood.rawValue)' should be hittable", file: file, line: line)
.forceTap(file: file, line: line)
}
func deleteEntry(file: StaticString = #filePath, line: UInt = #line) {
deleteButton.scrollIntoView(in: sheet, direction: .up, maxSwipes: 3, file: file, line: line)
deleteButton.forceTap(file: file, line: line)
let alert = app.alerts.firstMatch
alert.waitForExistenceOrFail(timeout: navigationTimeout, message: "Delete confirmation alert should appear", file: file, line: line)
let confirmDelete = alert.buttons.matching(NSPredicate(format: "label CONTAINS[cd] %@", "Delete")).firstMatch
confirmDelete
.waitForExistenceOrFail(timeout: defaultTimeout, message: "Delete button in alert should exist", file: file, line: line)
.forceTap(file: file, line: line)
}
// MARK: - Assertions
@discardableResult
func assertVisible(file: StaticString = #filePath, line: UInt = #line) -> EntryDetailScreen {
sheet.waitForExistenceOrFail(timeout: navigationTimeout, message: "Entry Detail sheet should be visible", file: file, line: line)
return self
}
func assertDismissed(file: StaticString = #filePath, line: UInt = #line) {
sheet.waitForNonExistence(timeout: navigationTimeout, message: "Entry Detail sheet should be dismissed", file: file, line: line)
}
}