user-event icon indicating copy to clipboard operation
user-event copied to clipboard

File Input bug when Uploading

Open cjduncana opened this issue 1 year ago • 1 comments

Reproduction example

https://codesandbox.io/p/sandbox/test-file-upload-xtg77s

Prerequisites

  1. Have an input element using the file type with an accept attribute with a comma-separated list that adds spaces between each value.
  2. 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.

cjduncana avatar Oct 19 '24 22:10 cjduncana

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.

cjduncana avatar Oct 19 '24 22:10 cjduncana

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

Shaglock avatar Sep 25 '25 09:09 Shaglock