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:
@@ -13,108 +13,81 @@ final class NoteEditTests: BaseUITestCase {
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
/// Opens the note editor for the first entry and types the given text.
|
||||
/// Returns the entry detail and note editor screens for further assertions.
|
||||
private func addNote(_ text: String) -> (detail: EntryDetailScreen, editor: NoteEditorScreen) {
|
||||
guard app.firstEntryRow.waitForExistence(timeout: 8) else {
|
||||
XCTFail("No entry row found")
|
||||
return (EntryDetailScreen(app: app), NoteEditorScreen(app: app))
|
||||
/// 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: defaultTimeout) {
|
||||
noteArea.forceTap()
|
||||
} else {
|
||||
noteButton.waitForExistenceOrFail(timeout: defaultTimeout, message: "Neither note area nor note button found")
|
||||
noteButton.forceTap()
|
||||
}
|
||||
app.firstEntryRow.tapWhenReady()
|
||||
|
||||
let noteEditor = NoteEditorScreen(app: app)
|
||||
noteEditor.assertVisible()
|
||||
return noteEditor
|
||||
}
|
||||
|
||||
/// Opens the first entry row and returns the detail screen.
|
||||
private func openFirstEntryDetail() -> EntryDetailScreen {
|
||||
app.firstEntryRow.waitForExistenceOrFail(timeout: navigationTimeout, message: "No entry row found")
|
||||
app.firstEntryRow.forceTap()
|
||||
|
||||
let detail = EntryDetailScreen(app: app)
|
||||
detail.assertVisible()
|
||||
return detail
|
||||
}
|
||||
|
||||
// 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 editor = NoteEditorScreen(app: app)
|
||||
editor.assertVisible()
|
||||
/// Adds a note with the given text and saves it.
|
||||
private func addNote(_ text: String) -> EntryDetailScreen {
|
||||
let detail = openFirstEntryDetail()
|
||||
let editor = openNoteEditor()
|
||||
editor.clearAndTypeNote(text)
|
||||
editor.save()
|
||||
editor.assertDismissed()
|
||||
|
||||
return (detail, editor)
|
||||
}
|
||||
|
||||
/// Re-opens the note editor from the current entry detail view.
|
||||
private func reopenNoteEditor() -> NoteEditorScreen {
|
||||
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 editor = NoteEditorScreen(app: app)
|
||||
editor.assertVisible()
|
||||
return editor
|
||||
return detail
|
||||
}
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
/// TC-133: Edit an existing note — add note, reopen, change text, verify new text.
|
||||
/// TC-133: Edit an existing note -- add note, reopen, change text, verify new text.
|
||||
func testEditNote_ExistingEntry() {
|
||||
// Step 1: Add initial note
|
||||
let (detail, _) = addNote("Original note text")
|
||||
let detail = addNote("Original note text")
|
||||
|
||||
// Verify initial note is visible
|
||||
let originalText = app.staticTexts.matching(
|
||||
NSPredicate(format: "label CONTAINS %@", "Original note text")
|
||||
).firstMatch
|
||||
XCTAssertTrue(
|
||||
originalText.waitForExistence(timeout: 5),
|
||||
"Original note should be visible"
|
||||
)
|
||||
originalText.waitForExistenceOrFail(timeout: navigationTimeout, message: "Original note should be visible")
|
||||
|
||||
captureScreenshot(name: "note_original")
|
||||
|
||||
// Step 2: Reopen and edit the note
|
||||
let editor = reopenNoteEditor()
|
||||
// Reopen and edit the note
|
||||
let editor = openNoteEditor()
|
||||
editor.clearAndTypeNote("Updated note text")
|
||||
editor.save()
|
||||
editor.assertDismissed()
|
||||
|
||||
// Step 3: Verify edited note is shown
|
||||
// Verify edited note is shown
|
||||
let updatedText = app.staticTexts.matching(
|
||||
NSPredicate(format: "label CONTAINS %@", "Updated note text")
|
||||
).firstMatch
|
||||
XCTAssertTrue(
|
||||
updatedText.waitForExistence(timeout: 5),
|
||||
"Updated note text should be visible after editing"
|
||||
)
|
||||
|
||||
captureScreenshot(name: "note_edited")
|
||||
updatedText.waitForExistenceOrFail(timeout: navigationTimeout, message: "Updated note text should be visible after editing")
|
||||
|
||||
detail.dismiss()
|
||||
detail.assertDismissed()
|
||||
}
|
||||
|
||||
/// TC-134: Add a long note (>1000 characters).
|
||||
/// TC-134: Add a long note (>1000 characters) and verify it saves.
|
||||
func testLongNote_Over1000Characters() {
|
||||
// Generate a long string > 1000 chars
|
||||
let longText = String(repeating: "This is a test note. ", count: 55) // ~1155 chars
|
||||
|
||||
// Add the long note
|
||||
let (detail, _) = addNote(longText)
|
||||
let detail = addNote(longText)
|
||||
|
||||
// Verify some portion of the note is visible
|
||||
let noteSnippet = app.staticTexts.matching(
|
||||
NSPredicate(format: "label CONTAINS %@", "This is a test note")
|
||||
).firstMatch
|
||||
XCTAssertTrue(
|
||||
noteSnippet.waitForExistence(timeout: 5),
|
||||
"Long note text should be visible after saving"
|
||||
)
|
||||
|
||||
captureScreenshot(name: "note_long_saved")
|
||||
noteSnippet.waitForExistenceOrFail(timeout: navigationTimeout, message: "Long note text should be visible after saving")
|
||||
|
||||
detail.dismiss()
|
||||
detail.assertDismissed()
|
||||
|
||||
Reference in New Issue
Block a user