dashboard-xhr.spec.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {
  2. interceptCompanionUrlMetaRequest,
  3. runRemoteUrlImageUploadTest,
  4. runRemoteUnsplashUploadTest,
  5. } from './reusable-tests'
  6. describe('Dashboard with XHR', () => {
  7. beforeEach(() => {
  8. cy.visit('/dashboard-xhr')
  9. })
  10. it('should upload remote image with URL plugin', () => {
  11. runRemoteUrlImageUploadTest()
  12. })
  13. it('should return correct file name with URL plugin from remote image with Content-Disposition', () => {
  14. const fileName = `DALL·E IMG_9078 - 学中文 🤑`
  15. cy.get('[data-cy="Url"]').click()
  16. cy.get('.uppy-Url-input').type(
  17. 'http://localhost:4678/file-with-content-disposition',
  18. )
  19. interceptCompanionUrlMetaRequest()
  20. cy.get('.uppy-Url-importButton').click()
  21. cy.wait('@url-meta').then(() => {
  22. cy.get('.uppy-Dashboard-Item-name').should('contain', fileName)
  23. cy.get('.uppy-Dashboard-Item-status').should('contain', '84 KB')
  24. })
  25. })
  26. it('should return correct file name with URL plugin from remote image without Content-Disposition', () => {
  27. cy.get('[data-cy="Url"]').click()
  28. cy.get('.uppy-Url-input').type('http://localhost:4678/file-no-headers')
  29. interceptCompanionUrlMetaRequest()
  30. cy.get('.uppy-Url-importButton').click()
  31. cy.wait('@url-meta').then(() => {
  32. cy.get('.uppy-Dashboard-Item-name').should('contain', 'file-no')
  33. cy.get('.uppy-Dashboard-Item-status').should('contain', '0')
  34. })
  35. })
  36. it('should return correct file name even when Companion doesnt supply it', () => {
  37. cy.intercept('POST', 'http://localhost:3020/url/meta', {
  38. statusCode: 200,
  39. headers: {},
  40. body: JSON.stringify({ size: 123, type: 'image/jpeg' }),
  41. }).as('url')
  42. cy.get('[data-cy="Url"]').click()
  43. cy.get('.uppy-Url-input').type(
  44. 'http://localhost:4678/file-with-content-disposition',
  45. )
  46. interceptCompanionUrlMetaRequest()
  47. cy.get('.uppy-Url-importButton').click()
  48. cy.wait('@url-meta').then(() => {
  49. cy.get('.uppy-Dashboard-Item-name').should('contain', 'file-with')
  50. cy.get('.uppy-Dashboard-Item-status').should('contain', '123 B')
  51. })
  52. })
  53. it('should upload remote image with Unsplash plugin', () => {
  54. runRemoteUnsplashUploadTest()
  55. })
  56. })