feat(expect): add toBeEditable locator matcher

Merged
BA
3d ago
+497-34

Adds expect(locator).toBeEditable(), Playwright's locator matcher: it waits for an enabled control that is not read-only.

await expect(screen.getByLabel('Email')).toBeEditable();
await expect(screen.getByLabel('Order id')).toBeEditable({ editable: false }); // read-only or disabled
  • Read-only is a node state the engine reports (SemanticNode.states.readonly), present only where a node has one. The matcher reads it; a disabled node is not editable either, read the same way as toBeEnabled.
  • Web: decided in-page as Playwright's getReadonly does. input, textarea, select by their readonly attribute alone; an element whose ARIA role takes aria-readonly by that attribute, case folded (an editing host by its ARIA role, so a plain <div contenteditable> stays editable and a td in a grid reads it); any other editing host and what is inside it false.
  • Mobile: only on Android, where agent-device's editable comes from TextView.isTextEditable(): a text field or search field gets readonly: !editable, a combobox readonly: false only when the platform says it takes text. iOS gets no state, because agent-device fills in editable: true for every iOS text field from its type.
  • Any node with no read-only state, like a button, fails both ways and the message names its role, as Playwright does.
  • The web and mobile engines require @e2e-dev/core and e2e at >=0.25.0 <1, since they emit a new contract field; toBeEditable needs those engine releases.
  • Types in packages/core/src/types.ts, pinned in tests/types/sdk-types.ts; MCP code surface lists the matcher.
  • Docs: reference/expect.mdx and the states union in reference/engine.mdx (en/ja/zh), the Playwright migration table; skill reference updated.

Issue

Part of #1855 (Assertions row, assigned).

Verified

Ran it locally: yes

  • packages/e2e/tests/unit/expect-async-editable.test.ts (10 cases: the engine state read both ways, disabled, editable: false, a node with no state, a secure field).
  • packages/e2e/tests/integration/web-platform.test.ts in Chromium, /editable-matcher: native readonly, aria-readonly with case folding, a fieldset-disabled input, an editing host and a line inside it, aria-readonly on an input (ignored), a role="textbox" editing host with aria-readonly, a plain contenteditable with aria-readonly (editable), a grid td editing host with aria-readonly (read-only), a button. 50 passed.
  • packages/mobile/tests/unit/nodes.test.ts: Android text fields both ways, Android combobox with editable: true, iOS TextView/TextField with the editable: true agent-device fills in (no state). Whole mobile unit suite 558 passed; @e2e-dev/web suite 856 passed, 1 skipped.
  • pnpm check clean.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • 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.
  • 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.