fix(upload): accept type should be more lenient
What:
Fixes a bug where file upload input[accept] is not respected when there are spaces in the accept attribute. Closes #1060.
Also raises an error in case the explicitly provided list of files did not have any match.
Why:
HTML attributes are notoriously lenient---if something is valid in HTML, then it should be valid in test cases. The accept attribute ignores both letter cases and whitespaces (including new lines). Plus it is very common for users to provide at least 1 space separator for for multi types, e.g. <input type="file" accept="image/png, image/jpeg" />.
Raising an error in case of empty filtered file list is more user-friendly than silently fail as a user's test case may fail anyway if an explicit call of upload was not successful.
How:
The PR handles these special cases using string replacement and case coercion.
Checklist:
- [x]
DocumentationN/A as this should be the default expected behavior. - [x] Tests
- [x] Ready to be merged
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 44b6498d57f3c7fd44bb90be25e24e9d9b307d4d:
| Sandbox | Source |
|---|---|
| userEvent-dom | Configuration |
| userEvent-react | Configuration |
| vibrant-morning-8w6ywc | Issue #1060 |
@ph-fritsche @Gpx @kentcdodds do you mind taking a look at this?
This looks good to me. I'm not an active maintainer on this package anymore so I don't think I should merge it, but if you don't get a reply in a day or so then I'll go ahead and merge it 👍
@ph-fritsche @Gpx @kentcdodds can we merge this?
Sorry nobody has replied on this PR.
Unfortunately it looks like in the time since this PR was updated, there were some dependencies that got changed which is likely what is causing the build failure. I'm afraid I don't have more time than to just click the "merge" button on this project, but it won't do any good if the build is failing. So this will have to wait until someone can adjust this PR to fix any build issues. Sorry.
@ktmud I'm sorry about the delay here. Some updates in our dependencies blocked our previous CI. We also learned that the previous CI wasn't sufficient to ensure that bug fixes we apply don't cause new problems in other environments. A new testing environment is already in place, but there still are some uncertainties that need to be resolved before a new version will be released. See the pinned issues and #1091 for details