|
@@ -4,6 +4,9 @@ type Tus = BaseTus & {
|
|
|
requests: { isPaused: boolean }
|
|
|
}
|
|
|
|
|
|
+// NOTE: we have to use different files to upload per test
|
|
|
+// because we are uploading to https://tusd.tusdemo.net,
|
|
|
+// constantly uploading the same images gives a different cached result (or something).
|
|
|
describe('Dashboard with Tus', () => {
|
|
|
beforeEach(() => {
|
|
|
cy.visit('/dashboard-tus')
|
|
@@ -13,6 +16,29 @@ describe('Dashboard with Tus', () => {
|
|
|
cy.intercept('http://localhost:3020/search/unsplash/*').as('unsplash')
|
|
|
})
|
|
|
|
|
|
+ it.only('should emit `error` and `upload-error` events on failed POST request', () => {
|
|
|
+ cy.get('@file-input').attachFile(['images/traffic.jpg'])
|
|
|
+
|
|
|
+ const error = cy.spy()
|
|
|
+ const uploadError = cy.spy()
|
|
|
+ cy.window().then(({ uppy }) => {
|
|
|
+ uppy.on('upload-error', uploadError)
|
|
|
+ uppy.on('error', error)
|
|
|
+ })
|
|
|
+
|
|
|
+ cy.get('.uppy-StatusBar-actionBtn--upload').click()
|
|
|
+
|
|
|
+ cy.intercept(
|
|
|
+ { method: 'POST', url: 'https://tusd.tusdemo.net/*', times: 1 },
|
|
|
+ { statusCode: 401, body: { code: 401, message: 'Expired JWT Token' } },
|
|
|
+ ).as('post')
|
|
|
+
|
|
|
+ cy.wait('@post').then(() => {
|
|
|
+ expect(error).to.be.called
|
|
|
+ expect(uploadError).to.be.called
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
it('should upload cat image successfully', () => {
|
|
|
cy.get('@file-input').attachFile('images/cat.jpg')
|
|
|
cy.get('.uppy-StatusBar-actionBtn--upload').click()
|
|
@@ -23,7 +49,7 @@ describe('Dashboard with Tus', () => {
|
|
|
})
|
|
|
|
|
|
it('should start exponential backoff when receiving HTTP 429', () => {
|
|
|
- cy.get('@file-input').attachFile(['images/cat.jpg', 'images/traffic.jpg'])
|
|
|
+ cy.get('@file-input').attachFile(['images/baboon.png'])
|
|
|
cy.get('.uppy-StatusBar-actionBtn--upload').click()
|
|
|
|
|
|
cy.intercept(
|