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

test: fix system-tests-firefox downloads flake #20547

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion system-tests/test/downloads_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('e2e downloads', () => {

systemTests.it('allows changing the downloads folder', {
project: 'downloads',
spec: '*',
spec: 'downloads_spec.ts',
config: {
downloadsFolder: 'cypress/dls',
video: false,
Expand Down