dashboard-transloadit.spec.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. describe('Dashboard with Transloadit', () => {
  2. beforeEach(() => {
  3. cy.visit('/dashboard-transloadit')
  4. cy.get('.uppy-Dashboard-input').as('file-input')
  5. cy.intercept('/assemblies/*').as('assemblies')
  6. cy.intercept('/resumable/*').as('resumable')
  7. })
  8. it('should upload cat image successfully', () => {
  9. cy.get('@file-input').attachFile('images/cat.jpg')
  10. cy.get('.uppy-StatusBar-actionBtn--upload').click()
  11. cy.wait('@assemblies')
  12. cy.wait('@resumable')
  13. cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
  14. })
  15. it('should close assembly polling when cancelled', () => {
  16. cy.get('@file-input').attachFile(['images/cat.jpg', 'images/traffic.jpg'])
  17. cy.get('.uppy-StatusBar-actionBtn--upload').click()
  18. cy.intercept({
  19. method: 'GET',
  20. url: '/assemblies/*',
  21. }).as('assemblyPolling')
  22. cy.intercept(
  23. { method: 'PATCH', pathname: '/files/*', times: 1 },
  24. { statusCode: 204, body: {} },
  25. )
  26. cy.intercept(
  27. { method: 'DELETE', pathname: '/resumable/files/*', times: 1 },
  28. { statusCode: 204, body: {} },
  29. )
  30. cy.wait('@assemblyPolling')
  31. cy.window().then(({ uppy }) => {
  32. expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).every((a: any) => a.pollInterval)).to.equal(true)
  33. })
  34. cy.get('button[data-cy=cancel]').click()
  35. cy.window().then(({ uppy }) => {
  36. expect(Object.values(uppy.getPlugin('Transloadit').activeAssemblies).some((a: any) => a.pollInterval)).to.equal(false)
  37. })
  38. })
  39. })