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:
@@ -10,91 +10,61 @@ import XCTest
|
||||
final class NotesTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "single_mood" }
|
||||
|
||||
/// TC-026 / TC-132: Add a note to an existing entry.
|
||||
func testAddNote_ToExistingEntry() {
|
||||
guard app.firstEntryRow.waitForExistence(timeout: 8) else {
|
||||
XCTFail("No entry row found")
|
||||
return
|
||||
}
|
||||
app.firstEntryRow.tapWhenReady()
|
||||
// MARK: - Helpers
|
||||
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
|
||||
// Tap the note area to open the note editor
|
||||
/// Opens the note editor from the entry detail screen.
|
||||
private func openNoteEditor() -> NoteEditorScreen {
|
||||
let noteButton = app.element(UITestID.EntryDetail.noteButton)
|
||||
let noteArea = app.element(UITestID.EntryDetail.noteArea)
|
||||
if !noteArea.waitForExistence(timeout: 3) {
|
||||
// Try the note button instead
|
||||
let noteButton = app.element(UITestID.EntryDetail.noteButton)
|
||||
guard noteButton.waitForExistence(timeout: 3) else {
|
||||
XCTFail("Neither note area nor note button found")
|
||||
return
|
||||
}
|
||||
noteButton.tapWhenReady()
|
||||
|
||||
if noteArea.waitForExistence(timeout: defaultTimeout) {
|
||||
noteArea.forceTap()
|
||||
} else {
|
||||
noteArea.tapWhenReady()
|
||||
noteButton.waitForExistenceOrFail(timeout: defaultTimeout, message: "Neither note area nor note button found")
|
||||
noteButton.forceTap()
|
||||
}
|
||||
|
||||
let noteEditor = NoteEditorScreen(app: app)
|
||||
noteEditor.assertVisible()
|
||||
return noteEditor
|
||||
}
|
||||
|
||||
// Type a note
|
||||
// MARK: - Tests
|
||||
|
||||
/// TC-026 / TC-132: Add a note to an existing entry and verify it is saved.
|
||||
func testAddNote_ToExistingEntry() {
|
||||
app.firstEntryRow.waitForExistenceOrFail(timeout: navigationTimeout, message: "No entry row found")
|
||||
app.firstEntryRow.forceTap()
|
||||
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
|
||||
let noteEditor = openNoteEditor()
|
||||
noteEditor.clearAndTypeNote("Had a great day today!")
|
||||
|
||||
captureScreenshot(name: "note_typed")
|
||||
|
||||
// Save the note
|
||||
noteEditor.save()
|
||||
|
||||
// Note editor should dismiss
|
||||
noteEditor.assertDismissed()
|
||||
|
||||
// Verify the note text is visible in the detail view
|
||||
let noteText = app.staticTexts.matching(NSPredicate(format: "label CONTAINS %@", "Had a great day today!")).firstMatch
|
||||
XCTAssertTrue(
|
||||
noteText.waitForExistence(timeout: 5),
|
||||
"Saved note text should be visible in entry detail"
|
||||
)
|
||||
noteText.waitForExistenceOrFail(timeout: navigationTimeout, message: "Saved note text should be visible in entry detail")
|
||||
|
||||
captureScreenshot(name: "note_saved")
|
||||
|
||||
// Dismiss detail
|
||||
detailScreen.dismiss()
|
||||
detailScreen.assertDismissed()
|
||||
}
|
||||
|
||||
/// TC-135: Add a note with emoji and special characters.
|
||||
func testAddNote_WithEmoji() {
|
||||
guard app.firstEntryRow.waitForExistence(timeout: 8) else {
|
||||
XCTFail("No entry row found")
|
||||
return
|
||||
}
|
||||
app.firstEntryRow.tapWhenReady()
|
||||
/// TC-135: Add a note with special characters and verify save completes.
|
||||
func testAddNote_WithSpecialCharacters() {
|
||||
app.firstEntryRow.waitForExistenceOrFail(timeout: navigationTimeout, message: "No entry row found")
|
||||
app.firstEntryRow.forceTap()
|
||||
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
|
||||
// Open note editor
|
||||
let noteArea = app.element(UITestID.EntryDetail.noteArea)
|
||||
if noteArea.waitForExistence(timeout: 3) {
|
||||
noteArea.tapWhenReady()
|
||||
} else {
|
||||
let noteButton = app.element(UITestID.EntryDetail.noteButton)
|
||||
noteButton.tapWhenReady()
|
||||
}
|
||||
|
||||
let noteEditor = NoteEditorScreen(app: app)
|
||||
noteEditor.assertVisible()
|
||||
|
||||
// Type emoji text - note: XCUITest typeText supports Unicode
|
||||
let noteEditor = openNoteEditor()
|
||||
noteEditor.clearAndTypeNote("Feeling amazing! #100")
|
||||
|
||||
// Save
|
||||
noteEditor.save()
|
||||
noteEditor.assertDismissed()
|
||||
|
||||
captureScreenshot(name: "note_with_special_chars")
|
||||
|
||||
detailScreen.dismiss()
|
||||
detailScreen.assertDismissed()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user