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>
96 lines
3.3 KiB
Swift
96 lines
3.3 KiB
Swift
//
|
|
// NoteEditTests.swift
|
|
// Tests iOS
|
|
//
|
|
// TC-133: Edit an existing note.
|
|
// TC-134: Long note (>1000 characters).
|
|
//
|
|
|
|
import XCTest
|
|
|
|
final class NoteEditTests: BaseUITestCase {
|
|
override var seedFixture: String? { "single_mood" }
|
|
|
|
// MARK: - Helpers
|
|
|
|
/// 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()
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
/// 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
|
|
}
|
|
|
|
// MARK: - Tests
|
|
|
|
/// TC-133: Edit an existing note -- add note, reopen, change text, verify new text.
|
|
func testEditNote_ExistingEntry() {
|
|
let detail = addNote("Original note text")
|
|
|
|
// Verify initial note is visible
|
|
let originalText = app.staticTexts.matching(
|
|
NSPredicate(format: "label CONTAINS %@", "Original note text")
|
|
).firstMatch
|
|
originalText.waitForExistenceOrFail(timeout: navigationTimeout, message: "Original note should be visible")
|
|
|
|
// Reopen and edit the note
|
|
let editor = openNoteEditor()
|
|
editor.clearAndTypeNote("Updated note text")
|
|
editor.save()
|
|
editor.assertDismissed()
|
|
|
|
// Verify edited note is shown
|
|
let updatedText = app.staticTexts.matching(
|
|
NSPredicate(format: "label CONTAINS %@", "Updated note text")
|
|
).firstMatch
|
|
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) and verify it saves.
|
|
func testLongNote_Over1000Characters() {
|
|
let longText = String(repeating: "This is a test note. ", count: 55) // ~1155 chars
|
|
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
|
|
noteSnippet.waitForExistenceOrFail(timeout: navigationTimeout, message: "Long note text should be visible after saving")
|
|
|
|
detail.dismiss()
|
|
detail.assertDismissed()
|
|
}
|
|
}
|