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

[Bug] Not adding file correctly "[object Promise]" contents always #51

Closed
philjones88 opened this issue Apr 2, 2019 · 8 comments
Closed
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@philjones88
Copy link

philjones88 commented Apr 2, 2019

Current behavior:

cy.get('input').upload(
      [{
        fileContent: 'foobar',
        fileName: 'dynamic.lic',
        mimeType: '',
        encoding: 'utf-8'
      }],
      {
        force: true,
        subjectType: 'drag-n-drop'
      });

Against an ng2-file-upload target https://github.com/valor-software/ng2-file-upload

The HTTP request then made by angular is:

------WebKitFormBoundaryuPJXUTfgfFPBd4cB
Content-Disposition: form-data; name="file"; filename="dynamic.lic"
Content-Type: application/octet-stream

[object Promise]
------WebKitFormBoundaryuPJXUTfgfFPBd4cB--

Which is wrong as it should be the file contents.

The angular app logging shows the file in ng2-file-upload as:

image

Desired behavior:

Should add the file properly

Steps to reproduce: (app code and test code)

Maybe try targeting these demo controls https://valor-software.com/ng2-file-upload/

Versions

Cypress 3.2.0
MacOS latest
Node LTS
Chrome

@philjones88 philjones88 added the bug Something isn't working label Apr 2, 2019
@abramenal abramenal added the help wanted Extra attention is needed label Apr 2, 2019
@philjones88
Copy link
Author

Was able to workaround it by using this approach from the thread I found this package in:

cypress-io/cypress#170 (comment)

@abramenal
Copy link
Owner

@philjones88 thanks for submitting the issue!

The only thing I've spotted is this async handlers mapping that may not work as we want it to:
https://github.com/abramenal/cypress-file-upload/blob/master/src/helpers/getFileBlob.js#L3

Will take a look later today if that is the cause, cuz the rest is actually the same as on the solution you mentioned, just encapsulated in the plugin.

@abramenal
Copy link
Owner

@philjones88 can you try out v3.0.7 I've just published? It should solve the issue.

@abramenal
Copy link
Owner

If your thing is fixed, I think it might be good to have a separate example folder for angular components related to file upload (like ng2-file-upload you mentioned).

@philjones88
Copy link
Author

@abramenal nice work, 3.0.7 works with drag-n-drop approach :) <3

@abramenal
Copy link
Owner

Yay perfect!
@allcontributors[bot] add @philjones88 for bug

@allcontributors
Copy link
Contributor

@abramenal

I've put up a pull request to add @philjones88! 🎉

@abramenal
Copy link
Owner

Will work on angular examples later on. Stay tuned :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants