// Nothing in Notes is out of reach at the end of a long list: the last of // seventy-odd invented notes can be scrolled to, stands clear of the New // note button and the home indicator, and opens, upright and at the largest // text. A held row's last act stands inside the safe area at the largest // text. Notes stays upright when the phone turns, as every Cotton iPhone // app. import XCTest final class NotesReachTests: NotesUITestCase { /// Scrolls to the end, opens the last row, and comes back. @MainActor private func theLastNoteOpens(_ app: XCUIApplication) throws { NotesUI.list(app) try skipUnderTheShellsCard(app) guard let last = NotesUI.scrollToTheEnd(app) else { return XCTFail("rows stand at the list's end") } XCTAssertTrue(NotesUI.inside(last.frame, app, bottom: 30), "the last row stands whole above the home indicator: \(last.label)") let compose = NotesUI.id(app, "notes-compose") if compose.exists { // The button stands over the list's foot, never over the last row's words. XCTAssertTrue(compose.frame.minY >= last.frame.maxY - 1 || compose.frame.maxX <= last.frame.minX, "the last row clears New note: row ends at \(last.frame.maxY), button at \(compose.frame.minY)") } NotesUI.point(app, last, CGVector(dx: 0.3, dy: 0.5)).tap() XCTAssertTrue(NotesUI.writer(app).waitForExistence(timeout: 5), "the last note opened") let back = NotesUI.id(app, "note-back") XCTAssertTrue(back.waitForExistence(timeout: 3), "the note has its Back") XCTAssertTrue(NotesUI.inside(back, app), "Back stands inside the safe area") back.tap() XCTAssertTrue(NotesUI.writer(app).waitForNonExistence(timeout: 5), "Back closed the note") } // RULE: upright, the last of the crowd can be reached, clears New note, and opens. @MainActor func testTheLastNoteCanBeReachedAndOpened() throws { let app = NotesUI.launch() try theLastNoteOpens(app) } // RULE: at the largest text, the last of the crowd can be reached, clears New note, and opens. @MainActor func testTheLastNoteCanBeReachedAndOpenedAtTheLargestText() throws { let app = NotesUI.launch(NotesUI.largestText) try theLastNoteOpens(app) } // RULE: at the largest text, every row has its words (none crushed to a blank tall row), and a held row's acts stand inside the safe area. @MainActor func testRowsAndActsAtTheLargestText() throws { let app = NotesUI.launch(NotesUI.largestText) NotesUI.list(app) try skipUnderTheShellsCard(app) for _ in 0..<3 { for row in NotesUI.rowsOnScreen(app) { XCTAssertFalse(row.label.trimmingCharacters(in: .whitespaces).isEmpty, "a row on screen has words (\(row.frame))") XCTAssertLessThan(row.frame.height, app.windows.firstMatch.frame.height * 0.7, "\(row.label) is no taller than most of the screen") } NotesUI.drag(app, from: CGVector(dx: 0.5, dy: 0.8), by: CGVector(dx: 0, dy: -400)) settle() } // Mid-screen; or, under the shell's card (the list's view then holds less than two rows), any row standing whole. guard let row = NotesUI.rowsOnScreen(app).first(where: { NotesUI.inside($0.frame, app, top: 120, bottom: 160) }) ?? NotesUI.wholeRow(app) else { return XCTFail("a row stands mid-screen") } NotesUI.point(app, row, CGVector(dx: 0.5, dy: 0.4)).press(forDuration: 0.9) let bin = NotesUI.id(app, "notes-act-bin") XCTAssertTrue(bin.waitForExistence(timeout: 3), "the hold opened the row's acts") for act in ["pin", "tags", "archive", "export", "bin"] { let one = NotesUI.id(app, "notes-act-\(act)") XCTAssertTrue(one.exists && NotesUI.inside(one, app), "\(act) stands inside the safe area at the largest text") } } // RULE: turning the phone changes nothing: Notes stays upright. @MainActor func testTurningThePhoneKeepsNotesUpright() { let app = NotesUI.launch() NotesUI.list(app) let before = app.windows.firstMatch.frame XCUIDevice.shared.orientation = .landscapeLeft settle(1) let after = app.windows.firstMatch.frame XCTAssertGreaterThan(after.height, after.width, "Notes stayed upright with the phone turned") XCTAssertEqual(before.size, after.size) } }