Cypress-file-upload: [Bug] Version 3.5.1 breaks drag/drop with Elm

Created on 19 Dec 2019  ·  5Comments  ·  Source: abramenal/cypress-file-upload

Current behavior:

Since version 3.5.1, drag/drop operations on pages written in Elm appear to do nothing. The problem is that the JavaScript generated by the Elm compiler has the following code which is executed when a drop operation occurs:

function _Json_isArray(value)
{
    return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
}

The drop operation is accepted only if this function returns true. However in version 3.5.1 it now returns false. The value which is sent into this function is a FileList, but value instanceof FileList returns false. We suspect this is because value is created in a different context from the running Elm code (which, when run in Cypress, is inside an iframe). Below is a screenshot of the debugger showing some relevant info:

cypress-file-upload-filelist

Desired behavior:

Downgrading to version 3.5.0 seems to resolve the problem, and we suspect this issue is caused by this recent change (to fix #133).

We wondered if maybe a configuration option could be made available to define whether to use the DataTransferObject or to revert to the original behaviour.

Steps to reproduce: (app code and test code)

See repo here: https://github.com/yonigibbs/elm-drag-drop-cypress

Versions

  • Cypress: 3.8.0
  • Cypress File Upload: 3.5.1
  • OS: Ubuntu 18.04
  • Browser: Chrome or Electron in Cypress
bug

All 5 comments

Hi @yonigibbs
Thanks for submitting the issue!
For sure this might be one of config parameters to pass. Let's investigate it together and figure out proper fix.
I am really impressed by the sample repo you've created, will let you know when I'm able to provide the fix for you 😄

Thank you!

@yonigibbs finally I've found the root cause. It appeared to be a bigger problem – whole plugin suite were using constructors from cypress' runner window, not the application's one. Thus, two different constructors and not working instanceof.

Similar thing but with File constructor is described here:
https://github.com/cypress-io/cypress/issues/933

Coming with fix in a while.

@all-contributors add @yonigibbs for bug

@abramenal

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

@yonigibbs released in v3.5.3

Brilliant! Thanks @abramenal. Much appreciated. Have grabbed v3.5.3 and can confirm it resolves the issue for us. 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zach446 picture zach446  ·  3Comments

HartiganHM picture HartiganHM  ·  7Comments

skjnldsv picture skjnldsv  ·  5Comments

craig-dae picture craig-dae  ·  5Comments

sanduteo95 picture sanduteo95  ·  7Comments