From 8f722804da9347b009c671686f987a907287a106 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 2 Aug 2022 23:07:55 +0200 Subject: [PATCH] e2e: mark tests as flaky (#3940) --- .../integration/dashboard-transloadit.spec.ts | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/e2e/cypress/integration/dashboard-transloadit.spec.ts b/e2e/cypress/integration/dashboard-transloadit.spec.ts index 9e08920941..f7a194e86e 100644 --- a/e2e/cypress/integration/dashboard-transloadit.spec.ts +++ b/e2e/cypress/integration/dashboard-transloadit.spec.ts @@ -1,3 +1,9 @@ +const FLAKY = { + retries: { + runMode: 3, // retry flaky test + }, +} + describe('Dashboard with Transloadit', () => { beforeEach(() => { cy.visit('/dashboard-transloadit') @@ -18,6 +24,33 @@ describe('Dashboard with Transloadit', () => { }) it('should close assembly polling when cancelled', () => { + cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true }) + cy.get('.uppy-StatusBar-actionBtn--upload').click() + + cy.intercept({ + method: 'GET', + url: '/assemblies/*', + }).as('assemblyPolling') + cy.intercept( + { method: 'PATCH', pathname: '/files/*', times: 1 }, + { statusCode: 204, body: {} }, + ) + cy.intercept( + { method: 'DELETE', pathname: '/resumable/files/*', times: 1 }, + { statusCode: 204, body: {} }, + ) + cy.wait('@assemblyPolling') + cy.window().then(({ uppy }) => { + expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).every((a: any) => a.pollInterval)).to.equal(true) + }) + cy.get('button[data-cy=cancel]').click() + + cy.window().then(({ uppy }) => { + expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).some((a: any) => a.pollInterval)).to.equal(false) + }) + }) + + it('should emit one assembly-cancelled event when cancelled', FLAKY, () => { const spy = cy.spy() cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true }) @@ -41,20 +74,16 @@ describe('Dashboard with Transloadit', () => { cy.wait('@assemblyPolling') cy.window().then(({ uppy }) => { uppy.on('transloadit:assembly-cancelled', spy) - expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).every((a: any) => a.pollInterval)).to.equal(true) }) cy.get('button[data-cy=cancel]').click() - cy.window().then(({ uppy }) => { - expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).some((a: any) => a.pollInterval)).to.equal(false) - }) cy.wait('@assemblyDeletion').then(() => { expect(spy).to.be.calledOnce }) }) - it('should close assembly polling when all files are removed', () => { - const spy = cy.stub() + it('should close assembly polling when all files are removed', FLAKY, () => { + const spy = cy.spy() cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true }) cy.get('.uppy-StatusBar-actionBtn--upload').click()