test(desktop-testbed): add a SwiftUI TaskBoard suite, and move the app process out of the surface (ENG-1533)

KD
3h ago
+1159-336

What

  • apps/desktop-testbed gets TaskBoard, a SwiftUI app, and an 18-test suite for the surfaces the AppKit form has none of. pnpm --filter @e2e-dev/desktop-testbed test runs it after the default suite.
  • Two driver fixes it turned up:
    • screen and desktop.windows() leave out the "Window sharing" button macOS 27 puts in a recorded window's title bar;
    • a collapsed toolbar search field reads as the button it is.
  • The launched app process moves out of surface.ts into app-process.ts.
  • The desktop reference says what the two fixes leave out and how the search field reads.

Why

  • Testbed: every live bug on #2322-#2324 sat in a surface the testbed had no control for. The SwiftUI window was agreed on #2324 as the follow-up that proves the fixes.
  • The two fixes:
    • whenever video was on, the Window sharing button showed up in screen as one of the app's controls, and desktop.windows() listed it as a second window;
    • TaskBoard's search field collapses at the window's first size, and read as a read-only text box no fill could reach.
  • The split: surface.ts was 1,848 lines, and the launch-and-quit state machine was the part okwasniewski asked to move out on #2323.

How it works

  1. app/macos-swiftui/TaskBoard.swift is okwasniewski's sample from #2324 plus a Keypad window with no control that takes keyboard focus.
    • scripts/build-macos.sh builds it beside the sign-in form, and e2e.swiftui.config.ts targets it.
    • tests-swiftui/taskboard.e2e.ts covers the cases #2324 listed, in the background only (the physical-input suite drives the sign-in form): Escape and Enter in a sheet, a check and a stepper as the first action in a fresh sheet, and a read four seconds after a press in a sheet with no pinned window.
    • It also covers a stepper value it cannot take (each refusal checked by its code and reason), the 200-row list past a sidebar that does not scroll, a popover read as visible, and an alert.
    • And the toolbar menu (By Title and By Priority, each checked by the order it gives), a list's text, a tap on row text, tabs in a second window opened with desktop.waitForWindow and left with desktop.window({ title }).activate(), and desktop.keyboard.press on the Keypad (the window API from main's #2403).
  2. system_title_bar_control (crates/e2e-desktop-napi/src/snapshot/chrome.rs, tests in snapshot/tests.rs) treats a direct child of the window as chrome when it is a menu button whose middle lies in the band the window's own title-bar buttons sit in, under one of the windows macOS draws over the title bar as the app's own: an on-screen window at the normal level that accessibility does not list, as the Window sharing button's is (windows::drawn_over_title_bar); an app's own panel there is listed and never counts, and when the accessibility list is empty or names a window with no id, nothing counts. The walk lists those windows only the first time such a menu button turns up, so an ordinary snapshot lists no windows. The button has no identifier and a localized title, so the rule goes by that drawn window; an app's own menu button has none and stays, in the band too. read_tree reads the window's chrome once for both the band and the chrome list.
  3. macOS also draws that button as a 66 by 20 point window of the app's own, which no accessibility element stands for. list (crates/e2e-desktop-napi/src/windows.rs) drops a window the accessibility tree does not list when it lies inside the top 60 points of a window it does list that is on screen, and above that window's bottom edge (drawn_in_title_bar). A helper window over the content, such as Calculator's mode picker, reaches lower and stays.
  4. roles.rs reads an AXButton with the AXSearchField subrole as button. It used to read as a textbox by the subrole alone.
  5. AppProcess (packages/desktop/src/app-process.ts) holds the moved code unchanged in behavior. It was moved again after the rebase onto main, from main's own launch code: the token passed as one argument (#2365), the hand-off clause of an unclaimed launch, and windowReadable in launch-wait.ts (#2368), which the surface still calls with the running_before list launch now returns:
    • the process id, start time, and token, and a launch whose outcome is unknown;
    • the launch record and the state directory;
    • launch, quitNow, running, and the queue that runs one launch or quit at a time.
    • The surface keeps what reads the screen, and onGone tells it when the process it read is gone. surface.ts goes from 1,867 to 1,608 lines. Main's #2458 types the launch options from the crate, and AppProcess.launch keeps that check (satisfies Partial<LaunchOptions>).
    • init calls clearLaunch before it loads the driver and sweeps old state directories, as before the move, and open creates the state directory after them.
  6. docs/reference/desktop.mdx says the Window sharing button and window macOS 27 adds to a recorded window are not read, and that a toolbar search field with no room reads as a Search button. The commit that shortened this stack's rows in the guide is gone: main's #2448 moved those rows into the reference page, where #2356 and #2357 wrote them short.

Issue

The SwiftUI testbed agreed on #2324, and the surface.ts split asked for on #2323.

Verified

Ran it locally: yes (macOS 27.2.1, arm64, background mode), at this head (44da48d83), restacked on main 7c1b2b258 and on this round's fixes in #2356 and #2357. snapshot.rs is 990 lines here: #2356 moved its tests into snapshot/tests.rs, and the title-bar helpers are in snapshot/chrome.rs. Main added tests to the default suite since, hence 31.

pnpm --filter @e2e-dev/desktop-testbed test
 Test Files  2 passed (2)
      Tests  31 passed (31)
 Test Files  1 passed (1)
      Tests  18 passed (18)
  • Checks at this head: pnpm run build, pnpm check, cargo fmt --check, clippy, cargo test (118 passed), native.ts regenerated with no change, and the desktop suite with the addon (340 passed). This PR changes no e2e or @e2e-dev/core code; the e2e unit suite (5141 passed, 2 skipped) ran at #2357's head.

  • Window sharing: at this head the SwiftUI suite passes 18 of 18 with --video on. While a window is recorded, a probe test finds no button "Window sharing", keeps button "Sort", and lists one window. That probe passes only because the drawn window is found: without it, the button would be read. Before this round, each of the suite's 21 video files opened in ffprobe. Before the window-list fix, the second-window test failed there on an extra "Window" in desktop.windows(). The tree has no "Window sharing" button and keeps the toolbar's "Sort" menu.

  • Search field: the filter test passes by tapping button "Search" first.

  • CodeRabbit, after that: a window of the app's own that accessibility lists, such as a utility panel, does not count as drawn over the title bar (unit test); checked live while recording, the Window sharing button is still left out.

  • cubic's findings this round: a menu-level window or a minimized window's frame is not counted as drawn over the title bar (unit test); a drawn window over the toolbar's menu button makes the depth guard's test fail when it is widened; the SwiftUI run writes its report to .e2e/swiftui; TaskBoard's Keypad keeps one key monitor, takes keypad digits, and lets Command, Control, and Option digits through; each row's priority has its own identifier; TaskBoard asks for macOS 13.

  • CodeRabbit's findings, each with a test that fails on the code before it: an app's own menu button directly in the window, in the title-bar band, stays with its menu; a window below a 30-point window's bottom edge is not part of its title bar; By Title sorts the Work project by title (the old app kept "Write release notes" first).

  • Unit tests: a toolbar menu button at the close button's height stays, and the window filter ignores a minimized window and one accessibility does not list. Mutants that widen the title-bar rule to level >= 2, or drop the on-screen check from the filter, each fail a test.

  • An AppKit crash: in two of eight full SwiftUI runs this round, TaskBoard quit mid-test (APP_NOT_OPEN). Its crash reports all show the same EXC_GUARD in AppKit's accessibility notification path (_NSAccessibilityNotify, _XMIGPostNotification), with none of the app's own code on the stack. The sign-in form has crashed with the same signature 14 times on this Mac since Nov 26, before this round. The other runs passed 18 of 18.

  • A flaky test: "opens a row context menu and chooses an item" failed 2 of 13 runs. Its secondaryTap reported success, but no menu showed. The cause is not found yet; it reads as a SwiftUI context menu that sometimes does not open in the background.

  • Not run: pnpm test:physical, since it moves the pointer of the person at this Mac, so Escape and Enter in a sheet are checked in the background only.

  • Videos from a run before the rebase: adding a task through the sheet, scrolling the 200-row list, the Preferences window's tabs, and keys sent to the Keypad window.

https://github.com/user-attachments/assets/7a8344eb-6d39-4a18-acd7-e2931d867a25

https://github.com/user-attachments/assets/afe17f1d-ba86-4a7a-87a9-2bd0b9217edd

https://github.com/user-attachments/assets/8fb3a547-46f8-4d0b-bb4e-8c0bbc58d5dc

https://github.com/user-attachments/assets/3c3fd1ab-fca6-4f76-988a-e0904bcc58a6

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. None: the testbed is private, and the pending .changeset/desktop-native-driver.md covers the driver fixes for the release that first ships it.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it. docs/reference/desktop.mdx and AGENTS.md's testbed paragraph.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

馃 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a macOS task board with task creation, duplication, completion, deletion, search, filtering, sorting, preferences, simulated syncing, and separate windows.
    • Added a dedicated end-to-end test suite for the task board, included in the desktop test command.
  • Bug Fixes
    • Improved handling of app launches and shutdowns, including cases where an app starts late.
    • Refined macOS window and accessibility reporting for title-bar controls and toolbar search fields.
  • Documentation
    • Clarified desktop test commands, including the separate physical-input suite, and documented toolbar search behavior and macOS 27 title-bar window reporting.