// // NotesTests.swift // Tests iOS // // Notes add/edit and emoji support tests. // import XCTest final class NotesTests: 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 } // 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!") noteEditor.save() 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 noteText.waitForExistenceOrFail(timeout: navigationTimeout, message: "Saved note text should be visible in entry detail") detailScreen.dismiss() detailScreen.assertDismissed() } /// 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() let noteEditor = openNoteEditor() noteEditor.clearAndTypeNote("Feeling amazing! #100") noteEditor.save() noteEditor.assertDismissed() detailScreen.dismiss() detailScreen.assertDismissed() } }