dashboard-ui.spec.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.close()', () => {
  8. cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
  9. cy.window().then(({ uppy }) => {
  10. expect(uppy.close()).to.not.throw
  11. })
  12. })
  13. it('should render thumbnails', () => {
  14. cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
  15. cy.get('.uppy-Dashboard-Item-previewImg')
  16. .should('have.length', 2)
  17. .each((element) => expect(element).attr('src').to.include('blob:'))
  18. })
  19. it('should support drag&drop', () => {
  20. cy.get('@drop-target').selectFile([
  21. 'cypress/fixtures/images/cat.jpg',
  22. 'cypress/fixtures/images/cat-symbolic-link',
  23. 'cypress/fixtures/images/cat-symbolic-link.jpg',
  24. 'cypress/fixtures/images/traffic.jpg',
  25. ], { action: 'drag-drop' })
  26. cy.get('.uppy-Dashboard-Item')
  27. .should('have.length', 4)
  28. cy.get('.uppy-Dashboard-Item-previewImg')
  29. .should('have.length', 3)
  30. .each((element) => expect(element).attr('src').to.include('blob:'))
  31. cy.window().then(({ uppy }) => {
  32. expect(JSON.stringify(uppy.getFiles().map(file => file.meta.relativePath))).to.be.equal('[null,null,null,null]')
  33. })
  34. })
  35. })