fix(web): support upload buttons that open file choosers
Merged
KU
18d ago+263+263+012345678901234567890123456789-10-10-01234567890123456789
What and why
upload(agent, MCP) andsetInputFilesfailed on a visible upload button over a hidden file input:locator.setInputFiles: Error: Node is not an HTMLInputElement.uploadFiles(packages/web/src/actions.ts): a file input, or a label for one, still takes the files directly (no click). Anything else is clicked with thefilechooserwait already attached, andFileChooser.setFilessets the files. No chooser isNOT_ACTIONABLE("opened no file chooser"), surfaced asACTION_FAILED.- One element resolve and one deadline cover the check, click, chooser wait, and
setFiles. A failed click leaves no unhandled rejection (would crashe2e mcp). A cancelled operation sets no files, even if the chooser opens after the cancel. - The agent
uploadtool description (packages/e2e/src/agent/primitives.ts) and thesetInputFilesjsdoc name the chooser button too. Changeset:e2eand@e2e-dev/webpatch.
await screen.getByRole('button', 'Choose avatar').setInputFiles('fixtures/attachment.txt');
Issue
Closes #954
Verified
Ran it locally: yes
packages/web/tests/integration/upload-actions.test.ts, real Chromium, locator and element handle: file input,<label for>over a hidden input (zero clicks), button over a hidden input, button that opens nothing.
| main | this branch |
|---|---|
button over hidden input: locator.setInputFiles: Error: Node is not an HTMLInputElement | Tests 8 passed (8) |
- Each new test fails without its fix: label lookup removed -> both label cases fail; signal checks removed -> the cancel unit test fails.
- Testbed
/controlswith the built CLI (node node_modules/e2e/dist/cli/bin.js run tests/controls.e2e.ts):Tests 18 passed (18), including "a button that opens a hidden file input takes the files" and "a button that opens no file chooser fails as ACTION_FAILED".