uppy.test.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* global browser, expect, capabilities */
  2. var path = require('path')
  3. var testURL = 'http://localhost:4567'
  4. function uppySelectFakeFile (uppyID) {
  5. var blob = new Blob(
  6. ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='],
  7. { type: 'image/svg+xml' }
  8. )
  9. window[uppyID].addFile({
  10. source: 'test',
  11. name: 'test-file',
  12. type: blob.type,
  13. data: blob
  14. })
  15. }
  16. function browserSupportsChooseFile (capabilities) {
  17. // Webdriver for Safari and Edge doesn’t support .chooseFile
  18. return capabilities.browserName !== 'safari' &&
  19. capabilities.browserName !== 'MicrosoftEdge'
  20. }
  21. browser.url(testURL)
  22. describe('File upload with DragDrop + Tus, DragDrop + XHRUpload, i18n translated string', () => {
  23. it('should upload a file with Tus and set progressbar to 100%', () => {
  24. if (browserSupportsChooseFile(capabilities)) {
  25. browser.chooseFile('#uppyDragDrop .uppy-DragDrop-input', path.join(__dirname, '../fixtures/image.jpg'))
  26. } else {
  27. browser.execute(uppySelectFakeFile, 'uppyDragDrop')
  28. }
  29. browser.pause(3000)
  30. var html = browser.getHTML('#uppyDragDrop-progress .UppyProgressBar-percentage', false)
  31. expect(parseInt(html)).to.be.equal(100)
  32. })
  33. it('should upload a file with XHRUpload and set progressbar to 100%', () => {
  34. if (browserSupportsChooseFile(capabilities)) {
  35. browser.chooseFile('#uppyi18n .uppy-DragDrop-input', path.join(__dirname, '../fixtures/image.jpg'))
  36. } else {
  37. browser.execute(uppySelectFakeFile, 'uppyi18n')
  38. }
  39. browser.pause(3000)
  40. var html = browser.getHTML('#uppyi18n-progress .UppyProgressBar-percentage', false)
  41. expect(parseInt(html)).to.be.equal(100)
  42. })
  43. it('should translate text strings into Russian', () => {
  44. var text = browser.getText('#uppyi18n .uppy-DragDrop-label')
  45. expect(text.trim()).to.be.equal('Перенесите файлы сюда или выберите')
  46. })
  47. })
  48. // it('another test', function () {
  49. // return browser
  50. // .url(uppyTestURL)
  51. // .chooseFile('#uppyDragDrop .uppy-DragDrop-input', path.join(__dirname, 'image.jpg'))
  52. // .pause(3000)
  53. // .getHTML('#uppyDragDrop-progress .UppyProgressBar-percentage', false).then(val => {
  54. // console.log(val)
  55. // expect(parseInt(val)).toBe(100)
  56. // })
  57. // })
  58. // })