dashboard-xhr.spec.ts 2.1 KB

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