diff --git a/e2e/cypress/integration/dashboard-transloadit.spec.ts b/e2e/cypress/integration/dashboard-transloadit.spec.ts index ad21ff0adb..f9087c3b8f 100644 --- a/e2e/cypress/integration/dashboard-transloadit.spec.ts +++ b/e2e/cypress/integration/dashboard-transloadit.spec.ts @@ -15,4 +15,31 @@ describe('Dashboard with Transloadit', () => { cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete') }) + + it('should close assembly polling when cancelled', () => { + cy.get('@file-input').attachFile(['images/cat.jpg', 'images/traffic.jpg']) + 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) + }) + }) }) diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index 8c4861ddf2..e6f27d1702 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "es5", - "lib": ["es5", "dom"], + "target": "es2020", + "lib": ["es2020", "dom"], "types": ["cypress", "cypress-file-upload"] }, "include": ["cypress/**/*.ts"] diff --git a/packages/@uppy/status-bar/src/Components.js b/packages/@uppy/status-bar/src/Components.js index 428e2edf5d..a034b0c51e 100644 --- a/packages/@uppy/status-bar/src/Components.js +++ b/packages/@uppy/status-bar/src/Components.js @@ -85,6 +85,7 @@ function CancelBtn (props) { title={i18n('cancel')} aria-label={i18n('cancel')} onClick={() => uppy.cancelAll()} + data-cy="cancel" data-uppy-super-focusable > { + if (reason === 'cancel-all') { + assembly.close() + this.uppy.off(fileRemovedHandler) + } else if (fileRemoved.id in updatedFiles) { + delete updatedFiles[fileRemoved.id] + if (Object.keys(updatedFiles).length === 0) { + assembly.close() + this.uppy.off(fileRemovedHandler) + } + } + } + this.uppy.on('file-removed', fileRemovedHandler) this.uppy.emit('transloadit:assembly-created', status, fileIDs)