feat(e2e)!: inputValue and isChecked throw on the wrong element, uncheck clicks ARIA radios

Merged
OK
12d ago
+126-36

Follows the Playwright gaps plan: two items, both decided "match Playwright".

  • inputValue() on a node with no value (a heading, a button) throws ACTION_FAILED with Playwright's message, instead of "". Same rule toHaveValue already uses (isValueControl in packages/e2e/src/internal/roles.ts): a value role with no value reported still reads "", since a device engine omits an empty value.
  • isChecked() on a node with no checked state throws ACTION_FAILED ("Not a checkbox or radio button"), instead of false. Checkable means a reported state or one of Playwright's kAriaCheckedRoles (checkbox, menuitemcheckbox, option, radio, switch, menuitemradio, treeitem), so an ARIA switch without aria-checked still reads false.
  • uncheck() on an ARIA role=radio clicks it, like Playwright. Only a native <input type=radio> refuses, with the same message as before. An ARIA radio whose click leaves it checked fails at the deadline with a hint about the radio group.
  • ACTION_FAILED because that is what check() on a wrong element already gives.
  • Breaking, so the changeset is minor with **Breaking:**. Docs updated: reference/screen.mdx, reference/errors.mdx, skills/e2e reads paragraph, and in migrate/playwright.mdx (on top of #1545) the check()/uncheck(), inputValue(), isChecked() rows and the toBeChecked note.
await screen.getByRole('heading', { level: 1 }).inputValue(); // ACTION_FAILED: Node is not an <input>, <textarea> or <select> element
await screen.getByRole('button', 'Save').isChecked();          // ACTION_FAILED: Not a checkbox or radio button

Marks removed (4 fail): check.e2e.ts "should uncheck radio by aria role", "should uncheck the box by aria role"; locator-convenience.e2e.ts "inputValue should work", "isChecked should work".

Callers checked: no agent, MCP, or engine code calls these reads; benchmarks read textbox/switch/checkbox nodes; two integration/unit tests that pinned ""/false on a heading/listitem now assert the throw.

Left as is, on purpose:

  • toBeChecked stays lenient (.not.toBeChecked() passes on a button). Not in scope; the migrate guide says so.
  • On a <label>, both reads now throw where Playwright reads the labeled control (before: a wrong false/""). Listed as missing in the migrate guide.
  • A custom-drawn iOS field reported as other with no value throws on inputValue(), as toHaveValue already does there.

Verified

Ran it locally: yes

  • testbed, node node_modules/e2e/dist/cli/bin.js run --tag playwright: 504 passed, 5 skipped, exit 0 (on main after #1546 and #1549). The 4 unmarked tests pass, "should throw when trying to uncheck radio button" still passes.
  • Probe test on the testbed (not committed), built CLI:
label checkbox isChecked ERR ACTION_FAILED Not a checkbox or radio button: locator("#l1")
label input inputValue   ERR ACTION_FAILED Node is not an <input>, <textarea> or <select> element: locator("#l2")
editable inputValue      "hello"
option inputValue        "x"
option isChecked         false
switch isChecked         false