// The side page pushes the list, it does not cover it (the owner, 22 Nov// 2026, WORDS-DRAWER.md). Opened by the menu button at the top left and by// the place's name, the page slides in from the left and the list moves right// with it, its left edge still showing in about the last fifth of the screen;// a tap on that edge closes it, and so does a drag on it. A swipe up or down// from the closed list's left edge still scrolls the list (d62146cefc). At the// default text size and the largest, light and dark. Invented crowd only;// shots words-drawer-* (WORDS_SHOTS, passed as TEST_RUNNER_WORDS_SHOTS).import XCTestfinalclassDrawerPushTests: NotesUITestCase {overridefunc tearDown() { XCUIDevice.shared.appearance = .lightsuper.tearDown() }privatefunc keep(_ name: String) {let screen = XCUIScreen.main.screenshot()let shot = XCTAttachment(screenshot: screen) shot.name = name shot.lifetime = .keepAlways add(shot)iflet dir = ProcessInfo.processInfo.environment["WORDS_SHOTS"], !dir.isEmpty {try? screen.pngRepresentation.write(to: URL(fileURLWithPath: dir).appendingPathComponent(name + ".png")) } }/// Waits until `element`'s frame has stood still for half a second (the spring has finished). @MainActor privatefunc still(_ element: XCUIElement) {var last = element.frame, same = 0for _ in0..<30where same < 3 { settle(0.2)let now = element.frame same = now == last ? same + 1 : 0 last = now } }/// The page stands open beside the list: the list's edge shows in about the last fifth, and the page's/// title stands under the clock, as the list's own header does. @MainActor privatefunc assertOpen(_ app: XCUIApplication, by: String, headerTop: CGFloat, shot: String? = nil) {let side = NotesUI.id(app, "side-page"), edge = NotesUI.id(app, "side-edge") XCTAssertTrue(side.waitForExistence(timeout: 3), "\(by) opened the side page") XCTAssertTrue(edge.waitForExistence(timeout: 3), "\(by): the list's edge stands beside the page") still(edge)iflet shot { keep(shot) }let width = app.windows.firstMatch.frame.widthlet showing = width - edge.frame.minX XCTAssertEqual(showing / width, 0.2, accuracy: 0.04, "\(by): the list moved right, a fifth of it showing (\(showing) of \(width))")let notes = NotesUI.id(app, "side-all") XCTAssertEqual(notes.frame.minX, 10, accuracy: 12, "\(by): the page stands at the left edge (\(notes.frame))") XCTAssertLessThanOrEqual(notes.frame.maxX, edge.frame.minX + 1, "\(by): the list stands right beside the page, not under it (\(notes.frame), \(edge.frame))") XCTAssertGreaterThan(notes.frame.maxX, edge.frame.minX - 30, "\(by): the page reaches the list's edge (\(notes.frame), \(edge.frame))")let title = NotesUI.id(app, "side-title") XCTAssertTrue(title.exists, "\(by): the page's title is drawn") XCTAssertGreaterThanOrEqual(title.frame.minY, headerTop - 8, "\(by): the page's title stands under the clock, as the list's header does") XCTAssertTrue(edge.isHittable, "\(by): the list's edge can be touched") } @MainActor privatefunc assertClosed(_ app: XCUIApplication, by: String) { XCTAssertTrue(NotesUI.id(app, "side-page").waitForNonExistence(timeout: 3), "\(by) closed the side page")let menu = NotesUI.id(app, "notes-menu") still(menu) XCTAssertEqual(NotesUI.id(app, "notes-place").frame.minX, menu.frame.maxX, accuracy: 30, "\(by): the list is back in its place") XCTAssertLessThan(menu.frame.minX, 20, "\(by): the list is back at the left edge") } @MainActor privatefunc walk(_ extra: [String], dark: Bool, _ shots: String) throws { XCUIDevice.shared.appearance = dark ? .dark : .lightlet app = NotesUI.launch(extra)NotesUI.list(app)let menu = NotesUI.id(app, "notes-menu"), place = NotesUI.id(app, "notes-place")try skipUnderTheShellsCard(app, [menu, place, NotesUI.id(app, "notes-more")]) XCTAssertTrue(menu.isHittable, "the menu button stands at the top left") XCTAssertLessThan(menu.frame.maxX, place.frame.minX + 12, "the menu button stands before the place's name") XCTAssertFalse(menu.label.isEmpty, "the menu button is named for VoiceOver")let headerTop = menu.frame.minY keep("words-drawer-\(shots)-closed") menu.tap() assertOpen(app, by: "the menu button", headerTop: headerTop, shot: "words-drawer-\(shots)-open")// A tap on the list's edge closes it. app.windows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0.92, dy: 0.5)).tap() assertClosed(app, by: "a tap on the list's edge") place.tap() assertOpen(app, by: "the place's name", headerTop: headerTop)// A drag on the list's edge to the left closes it.let start = app.windows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.6)) start.press(forDuration: 0.05, thenDragTo: start.withOffset(CGVector(dx: -260, dy: 0)), withVelocity: .fast, thenHoldForDuration: 0.05) assertClosed(app, by: "a drag on the list's edge")// A swipe up from the closed list's left edge scrolls it and opens nothing.for _ in0..<2 { NotesUI.drag(app, from: CGVector(dx: 0.5, dy: 0.8), by: CGVector(dx: 0, dy: -300)) } settle()// At the largest text a row is taller than half the list: any row standing in its lower part will do.let list = NotesUI.listFrame(app)guardlet row = NotesUI.seen(app).first(where: { $0.id == "notes-row" && $0.frame.height > 0 && $0.frame.minY > list.minY + list.height * 0.3 && $0.frame.minY < list.minY + list.height * 0.7 }) else { return XCTFail("a row stands in the list's lower part") }let edge = app.windows.firstMatch.coordinate(withNormalizedOffset: .zero).withOffset(CGVector(dx: 4, dy: row.frame.minY + 10)) edge.press(forDuration: 0.05, thenDragTo: edge.withOffset(CGVector(dx: 0, dy: -200)), withVelocity: .slow, thenHoldForDuration: 0.05) settle() XCTAssertLessThan(NotesUI.whereIs(app, row.label) ?? -1_000, row.frame.minY - 100, "a swipe up from the left edge scrolled the list") XCTAssertFalse(NotesUI.id(app, "side-page").exists, "a swipe up from the left edge opened nothing") }// RULE: the menu button and the place's name open the side page, which pushes the list right with a fifth showing; a tap or a drag on that edge closes it; a swipe up at the left edge still scrolls. @MainActor func testTheDrawerPushesTheListLight() throws { try walk([], dark: false, "light") } @MainActor func testTheDrawerPushesTheListDark() throws { try walk([], dark: true, "dark") } @MainActor func testTheDrawerPushesTheListAtTheLargestText() throws { try walk(NotesUI.largestText, dark: false, "largest") } @MainActor func testTheDrawerPushesTheListDarkAtTheLargestText() throws { try walk(NotesUI.largestText, dark: true, "dark-largest") }}