fix(e2e): let setInputFiles([]) clear a file input

Merged
OK
13d ago
+66-18
  • locator.setInputFiles([]) now clears a file input, both a file input and a control that opens a file chooser, and fires input and change, as in Playwright. It used to throw INVALID_ARGUMENT, so a test had no way to clear one.
  • Blank paths are still refused ('', ['a.txt', '']), now with setInputFiles paths must be non-empty strings (packages/e2e/src/locator/screen.ts:517).
  • The web engine needed no change: it already passes the list to Playwright's setInputFiles / fileChooser.setFiles, and both clear on []. Mobile still refuses setInputFiles entirely (UNSUPPORTED_CAPABILITY). The agent upload tool still needs at least one path.
  • Removes the skip on filechooser.e2e.ts "should be able to reset selected files with empty file list". set-input-files.e2e.ts has no other test that was left out for this reason (its two unported tests use in-memory buffers).
  • Docs: screen.mdx (now says web only), the engine action table, the e2e skill, and migrate/playwright.mdx: setInputFiles([]) moves from the "missing" row to the verbs row.
await screen.getByLabel('Receipt').setInputFiles('fixtures/receipt.pdf');
await screen.getByLabel('Receipt').setInputFiles([]); // cleared, input + change fired

Verified

Ran it locally: yes

  • testbed, node node_modules/e2e/dist/cli/bin.js run --tag playwright: 504 passed, 5 skipped (6 on main). The reset test passes: ✓ |web| tests/filechooser.e2e.ts > page filechooser > should be able to reset selected files with empty file list 179ms
  • testbed pnpm test (all tags): 580 passed, 6 skipped, 0 failed
  • new web integration test clears a file input and a chooser button, through both locator and element targets, and checks input then change fire
mainthis branch
setInputFiles([]) throws INVALID_ARGUMENT: setInputFiles requires one or more non-empty pathsclears the input, files.length is 0, input + change fire