// // NotesTests.swift // Tests iOS // // Notes add/edit and emoji support tests. // 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() { // Open entry detail let firstEntry = app.descendants(matching: .any) .matching(NSPredicate(format: "identifier BEGINSWITH %@", "entry_row_")) .firstMatch guard firstEntry.waitForExistence(timeout: 8) else { XCTFail("No entry row found") return } firstEntry.tap() let detailScreen = EntryDetailScreen(app: app) detailScreen.assertVisible() // Tap the note area to open the note editor let noteArea = app.buttons["entry_detail_note_area"] if !noteArea.waitForExistence(timeout: 3) { // Try the note button instead let noteButton = app.buttons["entry_detail_note_button"] guard noteButton.waitForExistence(timeout: 3) else { XCTFail("Neither note area nor note button found") return } noteButton.tap() } else { noteArea.tap() } // Note editor should appear let noteEditorTitle = app.navigationBars["Journal Note"] XCTAssertTrue( noteEditorTitle.waitForExistence(timeout: 5), "Note editor should be visible" ) // Type a note let textEditor = app.textViews["note_editor_text"] if textEditor.waitForExistence(timeout: 3) { textEditor.tap() textEditor.typeText("Had a great day today!") } captureScreenshot(name: "note_typed") // Save the note let saveButton = app.buttons["Save"] saveButton.tapWhenReady() // Note editor should dismiss XCTAssertTrue( noteEditorTitle.waitForDisappearance(timeout: 5), "Note editor should dismiss after save" ) // 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" ) captureScreenshot(name: "note_saved") // Dismiss detail detailScreen.dismiss() detailScreen.assertDismissed() } /// TC-135: Add a note with emoji and special characters. func testAddNote_WithEmoji() { let firstEntry = app.descendants(matching: .any) .matching(NSPredicate(format: "identifier BEGINSWITH %@", "entry_row_")) .firstMatch guard firstEntry.waitForExistence(timeout: 8) else { XCTFail("No entry row found") return } firstEntry.tap() let detailScreen = EntryDetailScreen(app: app) detailScreen.assertVisible() // Open note editor let noteArea = app.buttons["entry_detail_note_area"] if noteArea.waitForExistence(timeout: 3) { noteArea.tap() } else { let noteButton = app.buttons["entry_detail_note_button"] noteButton.tapWhenReady() } let noteEditorTitle = app.navigationBars["Journal Note"] XCTAssertTrue( noteEditorTitle.waitForExistence(timeout: 5), "Note editor should be visible" ) // Type emoji text - note: XCUITest typeText supports Unicode let textEditor = app.textViews["note_editor_text"] if textEditor.waitForExistence(timeout: 3) { textEditor.tap() textEditor.typeText("Feeling amazing! 100") } // Save let saveButton = app.buttons["Save"] saveButton.tapWhenReady() XCTAssertTrue( noteEditorTitle.waitForDisappearance(timeout: 5), "Note editor should dismiss after save" ) captureScreenshot(name: "note_with_special_chars") detailScreen.dismiss() detailScreen.assertDismissed() } }