fix(e2e): let setInputFiles([]) clear a file input
Merged
OK
13d ago+66+66+01234567890123456789-18-18-01234567890123456789
locator.setInputFiles([])now clears a file input, both a file input and a control that opens a file chooser, and firesinputandchange, as in Playwright. It used to throwINVALID_ARGUMENT, so a test had no way to clear one.- Blank paths are still refused (
'',['a.txt', '']), now withsetInputFiles 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 refusessetInputFilesentirely (UNSUPPORTED_CAPABILITY). The agentuploadtool still needs at least one path. - Removes the
skiponfilechooser.e2e.ts"should be able to reset selected files with empty file list".set-input-files.e2e.tshas 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, andmigrate/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
inputthenchangefire
| main | this branch |
|---|---|
setInputFiles([]) throws INVALID_ARGUMENT: setInputFiles requires one or more non-empty paths | clears the input, files.length is 0, input + change fire |