dashboard-ui.spec.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. describe('dashboard-ui', () => {
  2. beforeEach(() => {
  3. cy.visit('/dashboard-ui')
  4. cy.get('.uppy-Dashboard-input:first').as('file-input')
  5. cy.get('.uppy-Dashboard-AddFiles').as('drop-target')
  6. })
  7. it('should not throw when calling uppy.destroy()', () => {
  8. cy.get('@file-input').selectFile(
  9. [
  10. 'cypress/fixtures/images/cat.jpg',
  11. 'cypress/fixtures/images/traffic.jpg',
  12. ],
  13. { force: true },
  14. )
  15. cy.window().then(({ uppy }) => {
  16. expect(uppy.destroy()).to.not.throw
  17. })
  18. })
  19. it('should render thumbnails', () => {
  20. cy.get('@file-input').selectFile(
  21. [
  22. 'cypress/fixtures/images/cat.jpg',
  23. 'cypress/fixtures/images/traffic.jpg',
  24. ],
  25. { force: true },
  26. )
  27. cy.get('.uppy-Dashboard-Item-previewImg')
  28. .should('have.length', 2)
  29. .each((element) => expect(element).attr('src').to.include('blob:'))
  30. })
  31. it('should support drag&drop', () => {
  32. cy.get('@drop-target').selectFile(
  33. [
  34. 'cypress/fixtures/images/cat.jpg',
  35. 'cypress/fixtures/images/cat-symbolic-link',
  36. 'cypress/fixtures/images/cat-symbolic-link.jpg',
  37. 'cypress/fixtures/images/traffic.jpg',
  38. ],
  39. { action: 'drag-drop' },
  40. )
  41. cy.get('.uppy-Dashboard-Item').should('have.length', 4)
  42. cy.get('.uppy-Dashboard-Item-previewImg')
  43. .should('have.length', 3)
  44. .each((element) => expect(element).attr('src').to.include('blob:'))
  45. cy.window().then(({ uppy }) => {
  46. expect(
  47. JSON.stringify(uppy.getFiles().map((file) => file.meta.relativePath)),
  48. ).to.be.equal('[null,null,null,null]')
  49. })
  50. })
  51. })