Files
Reflect/Tests iOS/Screens/EntryDetailScreen.swift
Trey t 224341fd98 Fix remaining 17 UI test failures: group defaults, identifiers, hittability, date format
- resetAppState: use correct suite name to clear group defaults (fixes stale subscription state)
- Reorder configureIfNeeded: set expireTrial before IAPManager init
- Add browse_themes_button identifier to CustomizeView Browse Themes button
- Add mood_button_* identifiers to Entry Detail mood grid in NoteEditorView
- Use coordinate-based tap throughout all test screens (iOS 26 Liquid Glass hittability)
- Fix HeaderMoodLogging date format: M/d/yyyy → yyyy/MM/dd to match entry_row identifiers
- AppLaunchTests: wait for isSelected state with NSPredicate instead of immediate check
- OnboardingTests: add waits between swipes and retry logic for skip button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:46:18 -06:00

69 lines
2.2 KiB
Swift

//
// EntryDetailScreen.swift
// Tests iOS
//
// Screen object for the Entry Detail sheet (edit mood, notes, delete).
//
import XCTest
struct EntryDetailScreen {
let app: XCUIApplication
// MARK: - Elements
var navigationTitle: XCUIElement { app.navigationBars["Entry Details"] }
var doneButton: XCUIElement { app.buttons["entry_detail_done"] }
var deleteButton: XCUIElement { app.buttons["entry_detail_delete"] }
var moodGrid: XCUIElement { app.otherElements["entry_detail_mood_grid"] }
/// Mood buttons inside the detail sheet's mood grid.
/// Match by the mood_button_ identifier prefix to avoid matching entry rows.
func moodButton(for mood: MoodChoice) -> XCUIElement {
app.buttons["mood_button_\(mood.rawValue)"]
}
// MARK: - Actions
func dismiss() {
let button = doneButton
_ = button.waitForExistence(timeout: 5)
button.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
}
func selectMood(_ mood: MoodChoice) {
let button = moodButton(for: mood)
_ = button.waitForExistence(timeout: 5)
button.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
}
func deleteEntry() {
let button = deleteButton
_ = button.waitForExistence(timeout: 5)
button.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
// Confirm the delete alert
let deleteAlert = app.alerts["Delete Entry"]
let confirmButton = deleteAlert.buttons["Delete"]
_ = confirmButton.waitForExistence(timeout: 5)
confirmButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
}
// MARK: - Assertions
func assertVisible(file: StaticString = #file, line: UInt = #line) {
XCTAssertTrue(
navigationTitle.waitForExistence(timeout: 5),
"Entry Detail sheet should be visible",
file: file, line: line
)
}
func assertDismissed(file: StaticString = #file, line: UInt = #line) {
XCTAssertTrue(
navigationTitle.waitForDisappearance(timeout: 5),
"Entry Detail sheet should be dismissed",
file: file, line: line
)
}
}