fix(web): support upload buttons that open file choosers

Merged
KU
18d ago
+263-10

What and why

  • upload (agent, MCP) and setInputFiles failed 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 the filechooser wait already attached, and FileChooser.setFiles sets the files. No chooser is NOT_ACTIONABLE ("opened no file chooser"), surfaced as ACTION_FAILED.
  • One element resolve and one deadline cover the check, click, chooser wait, and setFiles. A failed click leaves no unhandled rejection (would crash e2e mcp). A cancelled operation sets no files, even if the chooser opens after the cancel.
  • The agent upload tool description (packages/e2e/src/agent/primitives.ts) and the setInputFiles jsdoc name the chooser button too. Changeset: e2e and @e2e-dev/web patch.
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.
mainthis branch
button over hidden input: locator.setInputFiles: Error: Node is not an HTMLInputElementTests 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 /controls with 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".