abramenal / cypress-file-upload

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

[Bug] File upload unsuccessful in Firefox, but successful in Chrome #319

Open symon-skelly opened 2 years ago

symon-skelly commented 2 years ago

Current behavior:

I am able to successfully use this plugin to upload photos & videos using Chrome Browser for e2e tests, however when the same tests are run in Firefox, the Video upload test will fail at the point where I am waiting for the video to finish uploading (it never does when using this plugin).

Desired behavior:

Firefox Browser should be able to successfully upload and process Videos in Cypress.

Steps to reproduce: (app code and test code)

Function used to upload Videos to our app:

function uploadVideo(fileName) { // Works for Chrome, not for Firefox?
  cy.fixture('Images/' + fileName, 'binary').then((fileContent) => {
    cy.get('.upload-area input', { timeout: 60000 }).attachFile({
      fileContent,
      fileName,
      mimeType: 'video/mp4',
      encoding: 'binary',
    }
  })
  cy.wait('@fileUploaded', { timeout: 60000 })
}

cy.intercept({
  method: 'POST',
  url: awsUrl
}).as('fileUploaded')

uploadVideo('Casino-14721.mp4')

The POST XHR to awsUrl, which is our Amazon AWS S3 bucket URL never resolves, causing the fileUploaded Route alias to never be matched, which in turn causes the timeout.

The video seemingly does get some way through uploading as I can click the 'loading' thumbnail that appears in our app and it displays the video, however it is not fully uploaded as it never progresses past this loading state.

image

If I upload the file manually using Firefox (via cypress) it uploads successfully and matches the Route as expected.

File that fails in Firefox but is successful in Chrome: https://user-images.githubusercontent.com/60613068/127124349-1db4b4b2-6fe0-4090-a652-ce728b8f5072.mp4

Versions

Cypress@8.0 cypress-file-upload@5.0.8 Chrome 91 Firefox 89

KleisKlasKluss commented 2 years ago

I'm experiencing the same thing using Firefox. The test works without problems in Edge and Chrome. In FF my test freeze at some point during upload, and the route doesn't match. I bit annoying.