dragdrop.spec.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var test = require('tape')
  2. var path = require('path')
  3. var core = require('./core')
  4. var browser = core.setDriver()
  5. var By = core.By
  6. var config = {
  7. dragDropTestUrl: 'http://localhost:4000/examples/dragdrop/',
  8. dragDropInputSelector: '.UppyDragDrop-One .UppyDragDrop-input',
  9. imageAbsolutePath: path.join(__dirname, 'image.jpg')
  10. }
  11. var consoleElement = browser.findElement(By.id('console-log'))
  12. test('dragdrop: make sure DragDrop accepts and uploads 1 file via input', function (t) {
  13. t.plan(1)
  14. // Go to the example URL
  15. browser.get(config.dragDropTestUrl)
  16. // Find input by css selector
  17. var input = browser.findElement(core.By.css(config.dragDropInputSelector))
  18. // Pass absolute image path to the input
  19. input.sendKeys(config.imageAbsolutePath)
  20. // Wait for a while for upload to go through
  21. browser.sleep(3000)
  22. // Get console elements’s value, then check if it has “Download” there somewhere,
  23. // if it does, then test passes
  24. consoleElement.getAttribute('value').then(function (value) {
  25. var isFileUploaded = value.indexOf('Download') !== -1
  26. t.equal(isFileUploaded, true)
  27. browser.quit()
  28. })
  29. })