abramenal / cypress-file-upload

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

[Bug] Ngx-dropzone duplicated events #291

Closed MikeDabrowski closed 3 years ago

MikeDabrowski commented 3 years ago

Current behavior:

When using this plugin to upload files onto ngx-dropzone (angular) the changes output fires twice. This happens when using subject 'drag-n-drop'. When using 'input' output fires once but the event that it is passed is of wrong type (CustomEvent). Current workaround would be to modify my app to handle that CustomEvent structure too, or to debounce that event.

Desired behavior:

It should only fire once.

Steps to reproduce: (app code and test code)

I'm pasting the most relevant pieces. If anything else is necessary please ask for it in the comment. When cypress executes this step, files are 'dropped' twice, and I got duplications all over the app.

<ngx-dropzone (change)="handleFileInput($event)" >
handleFileInput(stuff: NgxDropzoneChangeEvent) {
    console.log('handleInput', stuff); // fires twice
    //... handle files somehow ...
  }
const files = [{
     filePath: `pdfs/valid.pdf`,
      mimeType: 'application/pdf',
      encoding: 'utf-8',
}];
cy.get('ngx-dropzone')
      .should('exist')
      .attachFile(files, { subjectType: 'drag-n-drop' });

Versions

"ngx-dropzone": "^2.4.0",
"cypress-file-upload": "^5.0.4",
"cypress": "^7.0.0",
abramenal commented 3 years ago

Hi @MikeDabrowski Thanks for submitting the issue!

I think it is related to #290

abramenal commented 3 years ago

@MikeDabrowski v5.0.5 is just released, can you please check if this issue still persists?

MikeDabrowski commented 3 years ago

@abramenal I can confirm it works with v5.0.5. Good catch!

For anyone wondering: #290 removed 'change' event which was causing the output's second emission.