dragdrop.spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var test = require('tape')
  2. var path = require('path')
  3. var Driver = require('./Driver')
  4. var By = Driver.By
  5. var collectErrors = Driver.collectErrors
  6. test('dragdrop: make sure DragDrop accepts and uploads 1 file via input', function (t) {
  7. t.plan(1)
  8. var driver = Driver.setDriver()
  9. // Go to the example URL
  10. driver.get('http://localhost:4000/examples/dragdrop/')
  11. // Find input by css selector & pass absolute image path to it
  12. driver
  13. .findElement(By.css('.UppyDragDrop-One .UppyDragDrop-input'))
  14. .sendKeys(path.join(__dirname, 'image.jpg'))
  15. driver.sleep(30000)
  16. // Get console elements’s value, then check if it has “Download” there somewhere,
  17. // if it does, then test passes
  18. driver.findElement(By.id('console-log'))
  19. .getAttribute('value')
  20. .then(function (value) {
  21. var isFileUploaded = value.indexOf('Download') !== -1
  22. collectErrors(driver).then(function () {
  23. t.equal(isFileUploaded, true)
  24. driver.quit()
  25. })
  26. })
  27. // driver.wait(isUploadSuccessful, 5000).then(function (result) {
  28. // t.equal(result, true)
  29. // })
  30. // .catch(function (err) {
  31. // console.error('Something went wrong\n', err.stack, '\n')
  32. // })
  33. })