dragdrop.spec.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // Get console elements’s value, then check if it has “Download” there somewhere,
  16. // if it does, then test passes
  17. function isUploaded () {
  18. return driver.findElement(By.id('console-log'))
  19. .getAttribute('value')
  20. .then(function (value) {
  21. var isFileUploaded = value.indexOf('Download image.jpg') !== -1
  22. return isFileUploaded
  23. })
  24. }
  25. driver.wait(isUploaded, 15000, 'File image.jpg should be uploaded within 15 seconds')
  26. .then(function (result) {
  27. collectErrors(driver).then(function () {
  28. t.equal(result, true)
  29. driver.quit()
  30. })
  31. })
  32. .catch(function (err) {
  33. t.fail(err)
  34. driver.quit()
  35. })
  36. })