In Cypress 3.3.0, Cypress.Blob.base64StringToBlob doesn't work with pdf
See original GitHub issueCurrent behavior:
My test simulate a drop event to test React DropZone (https://github.com/react-dropzone/react-dropzone).
The test drop a base 64 encoded with Cypress.Blob.base64StringToBlob
pdf into the drop zone.
Since Cypress 3.3.0, the test fails.
The event is triggered but the endpoint that receive the pdf never answers. The process works if done by hand without Cypress so the endpoint works.
I have tested with other file type (png, jpeg …) and the test works. It only fails with pdf.
Desired behavior:
The pdf gets encoded properly to be sent in a formData
.
Steps to reproduce: (app code and test code)
The Cypress command that encode the file and trigger a drop event:
Cypress.Commands.add('dropFixtureInDropZone', (fixturePath, fixtureMime, dropZoneSelector) => {
const dropEvent = { dataTransfer: { files: [] } }
cy.fixture(fixturePath, 'base64').then(fixture => {
return Cypress.Blob.base64StringToBlob(fixture, fixtureMime).then(blob => {
dropEvent.dataTransfer.files.push(blob)
})
})
cy.get(dropZoneSelector).trigger('drop', dropEvent)
})
The function that calls it:
export const create_file = (cy, fileTitle = 'newFile') => {
cy.get('[data-cy=dropdownCreateBtn]').should('be.visible').click()
cy.get('.show .subdropdown__link__file__icon').should('be.visible').click()
cy.dropFixtureInDropZone('the_pdf.pdf', 'application/pdf', '.filecontent__form')
cy.get('[data-cy=popup__createcontent__form__button]')
.click()
cy.get('[data-cy="popinFixed"].file')
.should('be.visible')
cy.get(`.workspace__content__fileandfolder > .content[title="blob"] .fa.fa-paperclip`)
.should('be.visible')
}
The test fails at cy.get('[data-cy="popinFixed"].file')).should('be.visible')
because since the endpoint doesn’t answer, that dom element isn’t displayed
Versions
tested in cypress open and cypress run, with electron and chrome in Cypress 3.3.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (6 by maintainers)
Top GitHub Comments
Released in
3.3.1
.@skjnldsv That also looks like a duplicate of #4240, so no need to re-open for now