Skip to content

Commit

Permalink
e2e: mark tests as flaky (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Aug 2, 2022
1 parent 55581bc commit 8f72280
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions 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')
Expand All @@ -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 })
Expand All @@ -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()
Expand Down

0 comments on commit 8f72280

Please sign in to comment.