abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

[Bug] attachFile called once, but posting two files #276

Closed 8gentile closed 3 years ago

8gentile commented 3 years ago

Current behavior:

Attempting to use this package with react-dropzone and I have the following code which does everything I want except it does it twice for every time I call it.

cy.get('[data-testid=dropzone]')
      .attachFile(['media/diff.png'], {
        subjectType: 'drag-n-drop',
      })
      .wait('@postMedia');

Screen Shot 2021-03-01 at 6 09 03 PM

If I add a second call, I get four. Seems like it is performing an additional attachment even though I have a single file in the array.

Desired behavior:

I only want one file uploaded, without the copy.

Steps to reproduce: (app code and test code)

I'm using a small png file for upload. My fixture for the api request returns a single media uri and looks like this:

{
  "uri": "https://storage.googleapis.com/testimg.getrevvup.com/o/43be7942-11c6-4956-b377-c3c12ceb28e3.png"
}

Versions

 "cypress": "^6.5.0",
 "cypress-file-upload": "^5.0.2",
 "react-dropzone": "^11.3.1",
8gentile commented 3 years ago

For clarity, if I remove the processingOptions

{
     subjectType: 'drag-n-drop',
 }

I get only a single file, the expected behavior.

I'm reporting this bug for the drag and drop option.

boardofchris commented 3 years ago

Same issue with { subjectType: 'drag-n-drop' }. Attached is test runner showing two upload events.

Screen Shot 2021-03-02 at 3 13 28 PM

vitalii commented 3 years ago

any workarounds for it? Have the same issue

adamalston commented 3 years ago

One workaround is deleting the second uploaded file (from Cypress) so that only one file gets uploaded in the end. How to delete the duplicate upload would vary by project.

Rafsonic commented 3 years ago

Have the same issue