Stabilize iOS UI test foundation and fix flaky suites

This commit is contained in:
Trey t
2026-02-17 22:24:08 -06:00
parent c28d7a59eb
commit 56ac783219
38 changed files with 543 additions and 585 deletions

View File

@@ -19,13 +19,17 @@ struct DayScreen {
var horribleButton: XCUIElement { app.buttons["mood_button_horrible"] }
/// The mood header container
var moodHeader: XCUIElement { app.otherElements["mood_header"] }
var moodHeader: XCUIElement { app.element(UITestID.Day.moodHeader) }
// MARK: - Entry List
/// Find an entry row by its date string (format: "M/d/yyyy")
/// Find an entry row by its raw identifier date payload (yyyyMMdd).
func entryRow(dateString: String) -> XCUIElement {
app.descendants(matching: .any).matching(identifier: "entry_row_\(dateString)").firstMatch
app.element("\(UITestID.Day.entryRowPrefix)\(dateString)")
}
var anyEntryRow: XCUIElement {
app.firstEntryRow
}
// MARK: - Actions
@@ -37,7 +41,7 @@ struct DayScreen {
XCTFail("Mood button '\(mood.rawValue)' not found", file: file, line: line)
return
}
button.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
button.tapWhenReady(timeout: 5, file: file, line: line)
// Wait for the celebration animation to finish and entry to appear.
// The mood header disappears after logging today's mood.
@@ -70,6 +74,14 @@ struct DayScreen {
)
}
func assertAnyEntryExists(file: StaticString = #file, line: UInt = #line) {
XCTAssertTrue(
anyEntryRow.waitForExistence(timeout: 5),
"At least one entry row should exist",
file: file, line: line
)
}
// MARK: - Private
private func moodButton(for mood: MoodChoice) -> XCUIElement {