fix(mcp): draft a test line for every step a desktop session takes (ENG-1533)
What
e2e mcp's test lines replay what the session did, on every engine:
- The point tools (
tap_at,hover_at,type_at,press_at,select_at,drag_at) print a test line:screen.tapAt({ x, y })where the engine taps a bare point, else the locator line of the control under the point. A step no line can repeat says so (No test line: ...) and stays in the draft as a comment, where it used to be dropped silently. desktop.useWindow(window)is drafted by title,desktop.useWindow((await desktop.windows()).find((window) => window.title === "Inbox") ?? "titled Inbox"), not by a window id that is dead on the next launch. With no window of that title on replay, it fails with "the app has no window titled Inbox" rather than reading the focused one.- An action on a node id from an earlier observation writes the line of the node it acted on, found by the rule the action uses.
run_codein a session attached to a held test (open_session { attach }) has the engine's fixture (desktop,browser,device), one set for the whole attachment, as a standalone session's does.
Engines get one new optional field for this: FixtureOperation.testLine in @e2e-dev/core/engine. ExecutorNode from e2e/agent gains testId, as the listing already shows it. @e2e-dev/desktop's peer floor on @e2e-dev/core and e2e rises to >=0.25.1, the release with testLine.
Why
okwasniewski's e2e mcp pass on #2323 found each of these on a desktop app: a draft missing a tab tap and a field edit, a useWindow line that fails on replay, and an attached agent that could not switch back to the app's window (desktop is not defined).
How it works
FixtureOperation.testLine(packages/core/src/engine/index.ts:234) lets an engine say how a recorded fixture call is spelled in a test line:{ args }in place of the arguments, or{ note }kept as a comment.fixture-recording.ts:7passes it to the recorder, andwindowLine(packages/desktop/src/desktop.ts:71) draftsuseWindowby a non-empty title, ending with?? "titled <title>", an iduseWindowrefuses, sinceundefinedwould go back to the focused window.SessionTestLines(packages/e2e/src/session-tools/test-lines.ts:191) works out a point tool's target the way the action does and writespointCode(:818) or the control's own line.catalog.tsrecords the point tools' lines.- An id only an earlier observation listed is re-found on the newest screen by
refound(test-lines.ts:338), which calls the action's owndescribeTargetandrelocateDescriptor: role, name, test id, placeholder, and input purpose, the text only for a node with neither a name nor a test id. That needs the test id on each listed node, soprojectTreecopies it ontoExecutorNode(packages/core/src/agent/executor.ts:133).open_session's text and the reference say the same. createEngineFixtures(packages/core/src/run/fixtures.ts) builds an engine's fixtures over a session.buildCodeAttempt(packages/e2e/src/run/worker/held-test-tools.ts:419) gives the attachedrun_codefixtures over the held test's session with the attachment's own step recorder, so the calls stay out of the test's report and a--stephold never stops them. It builds them on the first call and keeps them for the attachment, so what a fixture holds (a web route) carries to the next call; each call enters its own phase of the attachment's one budget, cancelled with that call.docs/reference/mcp.mdx,docs/reference/engine.mdx,docs/desktop.mdx, andskills/e2e/references/mcp.mddescribe the lines and the field.
Acting on an earlier observation's id is kept rather than refused: SwiftUI renumbers a window on every change, so refusing would fail every second call in a batch. A secret fill still runs its checks on the node it found.
Issue
Review items from okwasniewski's e2e mcp pass on #2323.
Verified
Ran it locally: yes
- Unit tests for each line shape, and integration tests: the drafted lines,
.check()andscreen.tapAtamong them, replay in a real web run (mcp-test-lines.test.ts), and attachedrun_codecalls stay out of the held test's report (mcp-step-attachment.test.ts). - The fixes after review, each with a test that fails on the code before it: two "Delete" buttons told apart only by test id, renumbered and swapped, draft the one the tap touched; two nameless rows whose text swapped draft the row the action acted on; a property set on an attached fixture in one call is there in the next; and a drafted
useWindowline run with no "Inbox" window gives"titled Inbox". - Live, desktop testbed through
e2e mcp, background mode:tap_atprintedgetByRole("button", "Enable later").tap();useWindowdrafted the title line in a standalone and an attached session; the attachedrun_codeswitched to the Controls window and the resumed test read it and passed. scrollwhere nothing scrolls answersscroll down #n2 failed: ⦠nothing here scrolls down, not "may have reached the app" (checked live, no code change).
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. Patches fore2e,@e2e-dev/core, and@e2e-dev/desktop. - 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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it.docs/reference/mcp.mdx,docs/reference/engine.mdx,docs/desktop.mdx, andskills/e2e/references/mcp.md. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.FixtureOperation.testLineandExecutorNode.testIdare new optional fields; nothing else in the emitted.d.tschanges, andsdk-types.tsneeded no assertion for them. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile. The field is optional and only@e2e-dev/desktopsets it, so the web and mobile engines need no changeset.
š¤ Generated with Claude Code