Cypress-file-upload: [Bug] How to upload to Angular's ngx-dropzone

Created on 9 Dec 2019  路  8Comments  路  Source: abramenal/cypress-file-upload

Current behavior:

Hi!

I'm trying to use the provided examples to upload a file via drag n' drop to Angular's ngx-dropzone:

    const fileName = 'import-contacts-short.csv';

    cy.fixture(fileName).then(fileContent => {
      cy.get('[data-testid="dropzone"]').upload(
        { fileContent, fileName, mimeType: 'text/csv' },
        { subjectType: 'drag-n-drop' },
      );
    });

But I'm facing the following error:

image

This suggests that I should be passing a FileList, as .item is a property of this class, but I can't, since it is a readonly constructor. If ngx-dropzone is meant to be supported, is there any workaround to this?

Thanks in advance.

Desired behavior:

upload should support sending files via a FileList

bug

All 8 comments

Hi @thiagobrez
Thanks for submitting the issue!

Seems it should work naturally..
Which element has this data-testid="dropzone" attribute?
Can you please specify cypress and cypress-file-upload versions?

Let's fix this and possibly make a recipe with that plugin.

Hey @abramenal, thanks for the quick response!

The test id is on the dropzone itself:

<ngx-dropzone (change)="onSelect($event)" [multiple]="false" accept=".csv" data-testid="dropzone">
      ...
</ngx-dropzone>

Package versions are as following:

  "devDependencies": {
    "cypress": "^3.6.0",
    "cypress-file-upload": "^3.5.0"
  }

Also, I've set a breakpoint on the drop event and saw that the dataTransfer object looks different between cypress-file-upload run and actually dropping the file.

Real file drop:
image

cypress-file-upload drop:
image

@thiagobrez okay, now I see the problem! Perfect investigation! 馃憤
I recall my investigation about that API, as per MDN FileList object is read-only, however we can utilize DataTransfer API which uses it internally.

@all-contributors add @thiagobrez for bug

@abramenal

I've put up a pull request to add @thiagobrez! :tada:

@thiagobrez can you please test this in v3.5.1?

Wow, perfect! Just tested and it is working as intended.

@abramenal Thanks again for the package and quick response.

@thiagobrez thank you for the feedback and detailed investigation!
And welcome to the contributors list 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philjones88 picture philjones88  路  4Comments

harrison9149 picture harrison9149  路  7Comments

JaydenNavarro-at picture JaydenNavarro-at  路  5Comments

sandra-ouadghiri picture sandra-ouadghiri  路  3Comments

warpech picture warpech  路  4Comments