|
@@ -1,37 +1,40 @@
|
|
var test = require('tape')
|
|
var test = require('tape')
|
|
var path = require('path')
|
|
var path = require('path')
|
|
-var Browser = require('./Browser')
|
|
|
|
-var browser = Browser.setDriver()
|
|
|
|
-var By = Browser.By
|
|
|
|
-
|
|
|
|
-var config = {
|
|
|
|
- testUrl: 'http://localhost:4000/examples/dragdrop/',
|
|
|
|
- dragDropInputSelector: '.UppyDragDrop-One .UppyDragDrop-input',
|
|
|
|
- imagePath: path.join(__dirname, 'image.jpg')
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-var consoleElement = browser.findElement(By.id('console-log'))
|
|
|
|
|
|
+var Driver = require('./Driver')
|
|
|
|
+var By = Driver.By
|
|
|
|
+var collectErrors = Driver.collectErrors
|
|
|
|
|
|
test('dragdrop: make sure DragDrop accepts and uploads 1 file via input', function (t) {
|
|
test('dragdrop: make sure DragDrop accepts and uploads 1 file via input', function (t) {
|
|
t.plan(1)
|
|
t.plan(1)
|
|
|
|
|
|
- // Go to the example URL
|
|
|
|
- browser.get(config.testUrl)
|
|
|
|
|
|
+ var driver = Driver.setDriver()
|
|
|
|
|
|
- // Find input by css selector
|
|
|
|
- var input = browser.findElement(By.css(config.dragDropInputSelector))
|
|
|
|
|
|
+ // Go to the example URL
|
|
|
|
+ driver.get('http://localhost:4000/examples/dragdrop/')
|
|
|
|
|
|
- // Pass absolute image path to the input
|
|
|
|
- input.sendKeys(config.imagePath)
|
|
|
|
|
|
+ // Find input by css selector & pass absolute image path to it
|
|
|
|
+ driver
|
|
|
|
+ .findElement(By.css('.UppyDragDrop-One .UppyDragDrop-input'))
|
|
|
|
+ .sendKeys(path.join(__dirname, 'image.jpg'))
|
|
|
|
|
|
- // Wait for a while for upload to go through
|
|
|
|
- browser.sleep(3000)
|
|
|
|
|
|
+ driver.sleep(3000)
|
|
|
|
|
|
// Get console elements’s value, then check if it has “Download” there somewhere,
|
|
// Get console elements’s value, then check if it has “Download” there somewhere,
|
|
// if it does, then test passes
|
|
// if it does, then test passes
|
|
- consoleElement.getAttribute('value').then(function (value) {
|
|
|
|
- var isFileUploaded = value.indexOf('Download') !== -1
|
|
|
|
- t.equal(isFileUploaded, true)
|
|
|
|
- browser.quit()
|
|
|
|
- })
|
|
|
|
|
|
+ driver.findElement(By.id('console-log'))
|
|
|
|
+ .getAttribute('value')
|
|
|
|
+ .then(function (value) {
|
|
|
|
+ var isFileUploaded = value.indexOf('Download') !== -1
|
|
|
|
+ collectErrors(driver).then(function () {
|
|
|
|
+ t.equal(isFileUploaded, true)
|
|
|
|
+ driver.quit()
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // driver.wait(isUploadSuccessful, 5000).then(function (result) {
|
|
|
|
+ // t.equal(result, true)
|
|
|
|
+ // })
|
|
|
|
+ // .catch(function (err) {
|
|
|
|
+ // console.error('Something went wrong\n', err.stack, '\n')
|
|
|
|
+ // })
|
|
})
|
|
})
|