Real-world pattern not currently covered (<input type="file">).
Scope
- New page
examples/twd-test-app/src/pages/FileUpload.tsx:
- A single file input.
- Display the selected filename.
- Reject non-image files with a visible error message.
- Register the route in
examples/twd-test-app/src/routes.tsx and add a link from the App menu.
- New test file
examples/twd-test-app/src/twd-tests/file-upload.twd.test.ts:
- Query the input with
screenDom.getByLabelText(...).
- Happy path:
userEvent.upload(input, file) → filename appears (screenDom.getByText(...) + twd.should(el, "be.visible")).
- Invalid file type: error appears (
screenDom.getByRole("alert") or screenDom.getByTestId("upload-error")).
Reference
- Page structure:
examples/twd-test-app/src/pages/ComboboxSelect.tsx.
- Test structure:
examples/twd-test-app/src/twd-tests/combobox-select.twd.test.ts.
- Query pattern:
examples/twd-test-app/src/twd-tests/screen-queries.twd.test.ts.
Acceptance criteria
How to contribute
Read CONTRIBUTING.md first. Quick steps for this issue:
- Fork, clone, create a feature branch:
git checkout -b feat/file-upload-example.
- From the repo root, build the library and sync it to the example apps:
npm install
npm run build
npm run copy:mock-sw
- Install and run the test app:
cd examples/twd-test-app
npm install
npm run dev
- Open the app in the browser — the TWD sidebar appears on the right. Run your new tests from the sidebar and confirm they pass.
- Run the library's unit tests from the repo root:
npm run test:ci.
- Open the PR with screenshots of the sidebar showing green tests.
Always prefer screenDom (Testing Library) for element queries. Avoid twd.get() in new code.
Real-world pattern not currently covered (
<input type="file">).Scope
examples/twd-test-app/src/pages/FileUpload.tsx:examples/twd-test-app/src/routes.tsxand add a link from the App menu.examples/twd-test-app/src/twd-tests/file-upload.twd.test.ts:screenDom.getByLabelText(...).userEvent.upload(input, file)→ filename appears (screenDom.getByText(...)+twd.should(el, "be.visible")).screenDom.getByRole("alert")orscreenDom.getByTestId("upload-error")).Reference
examples/twd-test-app/src/pages/ComboboxSelect.tsx.examples/twd-test-app/src/twd-tests/combobox-select.twd.test.ts.examples/twd-test-app/src/twd-tests/screen-queries.twd.test.ts.Acceptance criteria
How to contribute
Read CONTRIBUTING.md first. Quick steps for this issue:
git checkout -b feat/file-upload-example.cd examples/twd-test-app npm install npm run devnpm run test:ci.