uppy.test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. capabilities.platformName !== 'Android'
  21. }
  22. browser.url(testURL)
  23. describe('File upload with DragDrop + Tus, DragDrop + XHRUpload, i18n translated string', () => {
  24. it('should upload a file with Tus and set progressbar to 100%', () => {
  25. if (browserSupportsChooseFile(capabilities)) {
  26. browser.chooseFile('#uppyDragDrop .uppy-DragDrop-input', path.join(__dirname, '../fixtures/image.jpg'))
  27. } else {
  28. browser.execute(uppySelectFakeFile, 'uppyDragDrop')
  29. }
  30. browser.pause(3000)
  31. var html = browser.getHTML('#uppyDragDrop-progress .UppyProgressBar-percentage', false)
  32. expect(parseInt(html)).to.be.equal(100)
  33. })
  34. it('should upload a file with XHRUpload and set progressbar to 100%', () => {
  35. if (browserSupportsChooseFile(capabilities)) {
  36. browser.chooseFile('#uppyi18n .uppy-DragDrop-input', path.join(__dirname, '../fixtures/image.jpg'))
  37. } else {
  38. browser.execute(uppySelectFakeFile, 'uppyi18n')
  39. }
  40. browser.pause(3000)
  41. var html = browser.getHTML('#uppyi18n-progress .UppyProgressBar-percentage', false)
  42. expect(parseInt(html)).to.be.equal(100)
  43. })
  44. it('should translate text strings into Russian', () => {
  45. var text = browser.getText('#uppyi18n .uppy-DragDrop-label')
  46. expect(text.trim()).to.be.equal('Перенесите файлы сюда или выберите')
  47. })
  48. })
  49. // it('another test', function () {
  50. // return browser
  51. // .url(uppyTestURL)
  52. // .chooseFile('#uppyDragDrop .uppy-DragDrop-input', path.join(__dirname, 'image.jpg'))
  53. // .pause(3000)
  54. // .getHTML('#uppyDragDrop-progress .UppyProgressBar-percentage', false).then(val => {
  55. // console.log(val)
  56. // expect(parseInt(val)).toBe(100)
  57. // })
  58. // })
  59. // })