feat(expect): add toBeEditable locator matcher
Merged
BA
3d ago+497+497+012345678901234567890123456789-34-34-01234567890123456789
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 astoBeEnabled. - Web: decided in-page as Playwright's
getReadonlydoes.input,textarea,selectby theirreadonlyattribute alone; an element whose ARIA role takesaria-readonlyby that attribute, case folded (an editing host by its ARIA role, so a plain<div contenteditable>stays editable and atdin a grid reads it); any other editing host and what is inside itfalse. - Mobile: only on Android, where agent-device's
editablecomes fromTextView.isTextEditable(): a text field or search field getsreadonly: !editable, a comboboxreadonly: falseonly when the platform says it takes text. iOS gets no state, because agent-device fills ineditable: truefor 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/coreande2eat>=0.25.0 <1, since they emit a new contract field;toBeEditableneeds those engine releases. - Types in
packages/core/src/types.ts, pinned intests/types/sdk-types.ts; MCP code surface lists the matcher. - Docs:
reference/expect.mdxand thestatesunion inreference/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.tsin Chromium,/editable-matcher: nativereadonly,aria-readonlywith case folding, a fieldset-disabled input, an editing host and a line inside it,aria-readonlyon an input (ignored), a role="textbox" editing host witharia-readonly, a plaincontenteditablewitharia-readonly(editable), a gridtdediting host witharia-readonly(read-only), a button. 50 passed.packages/mobile/tests/unit/nodes.test.ts: Android text fields both ways, Android combobox witheditable: true, iOSTextView/TextFieldwith theeditable: trueagent-device fills in (no state). Whole mobile unit suite 558 passed;@e2e-dev/websuite 856 passed, 1 skipped.pnpm checkclean.
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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.