Skip to content

Commit

Permalink
tweak fix to system-tests-firefox downloads spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel committed Mar 9, 2022
1 parent 9ec07e6 commit 83d42b9
Showing 1 changed file with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,7 @@ describe('downloads', () => {
})

it('handles csv file download', () => {
// HACK: monkey-patching Cypress.downloads.end to ensure the download has
// finished before asserting on its contents. this test was flakey b/c
// sometimes file was read before the browser had written its contents.
// consider creating events for downloads or some API, so that this can
// be done without hacks
const awaitDownload = new Promise<void>((resolve) => {
// @ts-ignore
const end = Cypress.downloads.end

// @ts-ignore
Cypress.downloads.end = (arg) => {
resolve()

return end(arg)
}
})

cy.get('[data-cy=download-csv]').click().then(() => {
return awaitDownload
})

cy.get('[data-cy=download-csv]').click()
cy
.readFile(`${Cypress.config('downloadsFolder')}/records.csv`)
.should('contain', '"Joe","Smith"')
Expand Down

0 comments on commit 83d42b9

Please sign in to comment.