dashboard-tus.spec.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. runRemoteUrlImageUploadTest,
  3. runRemoteUnsplashUploadTest,
  4. } from './reusable-tests.ts'
  5. // NOTE: we have to use different files to upload per test
  6. // because we are uploading to https://tusd.tusdemo.net,
  7. // constantly uploading the same images gives a different cached result (or something).
  8. describe('Dashboard with Tus', () => {
  9. beforeEach(() => {
  10. cy.visit('/dashboard-tus')
  11. cy.get('.uppy-Dashboard-input:first').as('file-input')
  12. cy.intercept('/files/*').as('tus')
  13. cy.intercept({ method: 'POST', pathname: '/files' }).as('post')
  14. cy.intercept({ method: 'PATCH', pathname: '/files/*' }).as('patch')
  15. })
  16. it('should upload cat image successfully', () => {
  17. cy.get('@file-input').selectFile('cypress/fixtures/images/cat.jpg', {
  18. force: true,
  19. })
  20. cy.get('.uppy-StatusBar-actionBtn--upload').click()
  21. cy.wait(['@post', '@patch']).then(() => {
  22. cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
  23. })
  24. })
  25. it('should start exponential backoff when receiving HTTP 429', () => {
  26. cy.get('@file-input').selectFile('cypress/fixtures/images/baboon.png', {
  27. force: true,
  28. })
  29. cy.intercept(
  30. { method: 'PATCH', pathname: '/files/*', times: 2 },
  31. { statusCode: 429, body: {} },
  32. ).as('patch')
  33. cy.get('.uppy-StatusBar-actionBtn--upload').click()
  34. cy.wait('@tus').then(() => {
  35. cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
  36. })
  37. })
  38. it('should upload remote image with URL plugin', () => {
  39. runRemoteUrlImageUploadTest()
  40. })
  41. it('should upload remote image with Unsplash plugin', () => {
  42. runRemoteUnsplashUploadTest()
  43. })
  44. })