Stabilize iOS UI test foundation and fix flaky suites
This commit is contained in:
@@ -12,58 +12,42 @@ final class NotesTests: BaseUITestCase {
|
||||
|
||||
/// 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 {
|
||||
guard app.firstEntryRow.waitForExistence(timeout: 8) else {
|
||||
XCTFail("No entry row found")
|
||||
return
|
||||
}
|
||||
firstEntry.tap()
|
||||
app.firstEntryRow.tapWhenReady()
|
||||
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
|
||||
// Tap the note area to open the note editor
|
||||
let noteArea = app.buttons["entry_detail_note_area"]
|
||||
let noteArea = app.element(UITestID.EntryDetail.noteArea)
|
||||
if !noteArea.waitForExistence(timeout: 3) {
|
||||
// Try the note button instead
|
||||
let noteButton = app.buttons["entry_detail_note_button"]
|
||||
let noteButton = app.element(UITestID.EntryDetail.noteButton)
|
||||
guard noteButton.waitForExistence(timeout: 3) else {
|
||||
XCTFail("Neither note area nor note button found")
|
||||
return
|
||||
}
|
||||
noteButton.tap()
|
||||
noteButton.tapWhenReady()
|
||||
} else {
|
||||
noteArea.tap()
|
||||
noteArea.tapWhenReady()
|
||||
}
|
||||
|
||||
// Note editor should appear
|
||||
let noteEditorTitle = app.navigationBars["Journal Note"]
|
||||
XCTAssertTrue(
|
||||
noteEditorTitle.waitForExistence(timeout: 5),
|
||||
"Note editor should be visible"
|
||||
)
|
||||
let noteEditor = NoteEditorScreen(app: app)
|
||||
noteEditor.assertVisible()
|
||||
|
||||
// Type a note
|
||||
let textEditor = app.textViews["note_editor_text"]
|
||||
if textEditor.waitForExistence(timeout: 3) {
|
||||
textEditor.tap()
|
||||
textEditor.typeText("Had a great day today!")
|
||||
}
|
||||
noteEditor.clearAndTypeNote("Had a great day today!")
|
||||
|
||||
captureScreenshot(name: "note_typed")
|
||||
|
||||
// Save the note
|
||||
let saveButton = app.buttons["Save"]
|
||||
saveButton.tapWhenReady()
|
||||
noteEditor.save()
|
||||
|
||||
// Note editor should dismiss
|
||||
XCTAssertTrue(
|
||||
noteEditorTitle.waitForDisappearance(timeout: 5),
|
||||
"Note editor should dismiss after 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
|
||||
@@ -81,48 +65,33 @@ final class NotesTests: BaseUITestCase {
|
||||
|
||||
/// 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 {
|
||||
guard app.firstEntryRow.waitForExistence(timeout: 8) else {
|
||||
XCTFail("No entry row found")
|
||||
return
|
||||
}
|
||||
firstEntry.tap()
|
||||
app.firstEntryRow.tapWhenReady()
|
||||
|
||||
let detailScreen = EntryDetailScreen(app: app)
|
||||
detailScreen.assertVisible()
|
||||
|
||||
// Open note editor
|
||||
let noteArea = app.buttons["entry_detail_note_area"]
|
||||
let noteArea = app.element(UITestID.EntryDetail.noteArea)
|
||||
if noteArea.waitForExistence(timeout: 3) {
|
||||
noteArea.tap()
|
||||
noteArea.tapWhenReady()
|
||||
} else {
|
||||
let noteButton = app.buttons["entry_detail_note_button"]
|
||||
let noteButton = app.element(UITestID.EntryDetail.noteButton)
|
||||
noteButton.tapWhenReady()
|
||||
}
|
||||
|
||||
let noteEditorTitle = app.navigationBars["Journal Note"]
|
||||
XCTAssertTrue(
|
||||
noteEditorTitle.waitForExistence(timeout: 5),
|
||||
"Note editor should be visible"
|
||||
)
|
||||
let noteEditor = NoteEditorScreen(app: app)
|
||||
noteEditor.assertVisible()
|
||||
|
||||
// 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")
|
||||
}
|
||||
noteEditor.clearAndTypeNote("Feeling amazing! #100")
|
||||
|
||||
// Save
|
||||
let saveButton = app.buttons["Save"]
|
||||
saveButton.tapWhenReady()
|
||||
|
||||
XCTAssertTrue(
|
||||
noteEditorTitle.waitForDisappearance(timeout: 5),
|
||||
"Note editor should dismiss after save"
|
||||
)
|
||||
noteEditor.save()
|
||||
noteEditor.assertDismissed()
|
||||
|
||||
captureScreenshot(name: "note_with_special_chars")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user