Bladeren bron

e2e: add test for retrying and pausing uploads (#3599)

Antoine du Hamel 1 jaar geleden
bovenliggende
commit
9d49a22a06

+ 23 - 0
e2e/cypress/integration/dashboard-aws-multipart.spec.ts

@@ -95,4 +95,27 @@ describe('Dashboard with @uppy/aws-s3-multipart', () => {
     cy.wait(['@createMultipartUpload-attempt3', '@signPart-attempt3', '@put-attempt3', '@completeMultipartUpload-attempt3'])
     cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
   })
+
+  it('should complete when resuming after pause', () => {
+    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.wait('@post')
+
+    cy.get('button[data-cy=togglePauseResume]').click()
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(300) // Wait an arbitrary amount of time as a user would do.
+    cy.get('button[data-cy=togglePauseResume]').click()
+
+    cy.wait('@get')
+
+    cy.get('button[data-cy=togglePauseResume]').click()
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(300) // Wait an arbitrary amount of time as a user would do.
+    cy.get('button[data-cy=togglePauseResume]').click()
+
+    cy.wait(['@get', '@put'])
+
+    cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
+  })
 })

+ 37 - 0
e2e/cypress/integration/dashboard-transloadit.spec.ts

@@ -360,6 +360,43 @@ describe('Dashboard with Transloadit', () => {
     // SECOND ATTEMPT
     cy.get('.uppy-StatusBar-actions > .uppy-c-btn').click()
     cy.wait(['@createAssembly-attempt2', '@tusCall-attempt2', '@assemblyCompleted-attempt2'])
+  })
+
+  it('should complete on retry', () => {
+    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('POST', 'https://transloaditstatus.com/client_error', {
+      statusCode: 200,
+      body: '{}',
+    })
+
+    cy.intercept(
+      { method: 'POST', pathname: '/assemblies', times: 1 },
+      { statusCode: 500, body: {} },
+    ).as('failedAssemblyCreation')
+
+    cy.wait('@failedAssemblyCreation')
+    cy.get('button[data-cy=retry]').click()
+
+    cy.wait(['@assemblies', '@resumable'])
+
+    cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
+  })
+
+  it('should complete when resuming after pause', () => {
+    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.wait('@createAssemblies')
+
+    cy.get('button[data-cy=togglePauseResume]').click()
+    // eslint-disable-next-line cypress/no-unnecessary-waiting
+    cy.wait(300) // Wait an arbitrary amount of time as a user would do.
+    cy.get('button[data-cy=togglePauseResume]').click()
+
+    cy.wait('@resumable')
+
     cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
   })
 })

+ 2 - 0
packages/@uppy/status-bar/src/Components.jsx

@@ -58,6 +58,7 @@ function RetryBtn (props) {
       aria-label={i18n('retryUpload')}
       onClick={() => uppy.retryAll().catch(() => { /* Error reported and handled via an event */ })}
       data-uppy-super-focusable
+      data-cy="retry"
     >
       <svg
         aria-hidden="true"
@@ -132,6 +133,7 @@ function PauseResumeButton (props) {
       className="uppy-u-reset uppy-StatusBar-actionCircleBtn"
       type="button"
       onClick={togglePauseResume}
+      data-cy="togglePauseResume"
       data-uppy-super-focusable
     >
       <svg