fallback.spec.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var test = require('tape')
  2. var path = require('path')
  3. var tools = require('./tools')
  4. module.exports = function (driver, platform, host) {
  5. var testName = 'Fallback: fall back to regular <form> upload when JS is not working, or not loaded yet, or browser is not supported by Uppy'
  6. test(tools.prettyTestName(testName, platform), function (t) {
  7. t.plan(1)
  8. driver.get(host + '/examples/multipart/index.html')
  9. driver.manage().window().maximize()
  10. tools.setSauceTestName(driver, testName)
  11. driver
  12. .findElement({css: '.UppyForm input'})
  13. .sendKeys(path.join(__dirname, 'image.jpg'))
  14. // driver.switchTo().alert().dismiss()
  15. // .catch(function (err) {
  16. // console.log(err)
  17. // })
  18. driver.findElement({css: '.UppyForm button'}).click()
  19. function isRedirectedAfterUpload () {
  20. // this should close the “Do you want to save this file?” alert when Travis runs the test
  21. return driver.getCurrentUrl().then(function (val) {
  22. console.log('current url is ', val)
  23. var isPageRedirected = val.indexOf('api2.transloadit.com') !== -1
  24. return isPageRedirected
  25. })
  26. }
  27. driver.wait(isRedirectedAfterUpload, 12000, 'Browser should navigate to api2.transloadit.com after upload')
  28. .then(function (isPageRedirected) {
  29. tools.testEqual(driver, t, isPageRedirected === true)
  30. driver.quit()
  31. })
  32. .catch(function (err) {
  33. tools.collectErrors(driver).then(function () {
  34. tools.testFail(driver, t, err)
  35. driver.quit()
  36. })
  37. })
  38. })
  39. }