user-event
user-event copied to clipboard
File Input bug when Uploading
Reproduction example
https://codesandbox.io/p/sandbox/test-file-upload-xtg77s
Prerequisites
- Have an input element using the file type with an accept attribute with a comma-separated list that adds spaces between each value.
- Write a test that uses the upload function on a file that matches one of the latter values in the accept attribute.
Expected behavior
The file input should have the uploaded file.
Actual behavior
The onChange event is not triggered, and the file input doesn't have the uploaded file.
User-event version
^14.1.1
Environment
No response
Additional context
The problem lies in the isAcceptableFile function. After splitting the string by its commas, it doesn't trim the whitespace, so some valid comma-separated tokens fail this test.
It's my first time contributing to this project. Once I have time, I can look into how to write an MR following your standards.
Hello, I faced the same issue and I noticed that #1064 resolved the problem. It's in the 14.6.1 release https://github.com/testing-library/user-event/releases/tag/v14.6.1. This issue can be closed I think @ph-fritsche