Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test when reading uploaded file with FormData #1109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

esamattis
Copy link

@esamattis esamattis commented Mar 25, 2023

What:
Just adding a failing test for a bug I found. It seems to be impossible to read a file added to a form with userEvent.upload() using FormData. See the test.

The FormData returns file object but it is empty. No name set to it and the type is application/octet-stream. I think it should be the same file object passed the the upload helper.

I was trying the test React Zorm file capabilities with this but got stuck due to this bug

See esamattis/react-zorm#37

Why:

I think this should work.

How:

It's not.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

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 2ac04eb:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration

@ph-fritsche
Copy link
Member

The DOM implementations prevent setting the HTMLInputElement.files property to a non-empty value (or manipulating or even creating a FileList.
We work around by replacing the property on the element.
The FormData constructor populates the object with data from the internal implementations of the input elements though.
We could only replace the window.FormData constructor with our own during setup.

esamattis added a commit to esamattis/react-zorm that referenced this pull request Mar 25, 2023
esamattis added a commit to esamattis/react-zorm that referenced this pull request Mar 25, 2023
@esamattis
Copy link
Author

esamattis commented Mar 25, 2023

Thanks for the reply! I used the FormData replacement as a workaround for React Zorm if anyone is interested:

esamattis/react-zorm@9c116a8

esamattis added a commit to esamattis/react-zorm that referenced this pull request Mar 25, 2023
esamattis added a commit to esamattis/react-zorm that referenced this pull request Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants