Przeglądaj źródła

remove old acceptance tests

Artur Paikin 7 lat temu
rodzic
commit
b3a9a4bdb7

+ 0 - 70
test/acceptance/dragdrop.spec.js

@@ -1,70 +0,0 @@
-var test = require('tape')
-var path = require('path')
-var tools = require('./tools')
-
-module.exports = function (driver, platform, host) {
-  var testName = 'DragDrop: upload one file'
-
-  test(tools.prettyTestName(testName, platform), function (t) {
-    t.plan(1)
-
-    // Go to the example URL
-    driver.get(host + '/examples/dragdrop/')
-    driver.manage().window().maximize()
-
-    // Set Saucelabs test name
-    tools.setSauceTestName(driver, testName)
-
-    driver.executeScript(tools.uppySelectFakeFile)
-    driver.findElement({css: '.UppyDragDrop-Two-Upload'}).click()
-
-    var platformBrowser = platform.browser.toLowerCase()
-    if (platformBrowser === 'safari' || platformBrowser === 'microsoftedge') {
-      console.log('fake-selecting a fake file')
-      driver.executeScript(tools.uppySelectFakeFile)
-      driver.findElement({css: '.UppyDragDrop-Two-Upload'}).click()
-    } else {
-      console.log('selecting a real file')
-      // Make file input “visible”
-      driver.executeScript('document.querySelector(".UppyDragDrop-One .uppy-DragDrop-input").style.opacity = 1')
-
-      // Find input by css selector & pass absolute image path to it
-      driver
-        .findElement({css: '.UppyDragDrop-One .uppy-DragDrop-input'})
-        .sendKeys(path.join(__dirname, 'image.jpg'))
-    }
-
-    function isUploaded () {
-      // return driver.findElement(By.id('console-log'))
-      //   .getAttribute('value')
-      //   .then(function (value) {
-      //     var isFileUploaded = value.indexOf('Download image.jpg') !== -1
-      //     return isFileUploaded
-      //   })
-
-      // .getText() only work on visible elements, so we use .getAttribute('textContent'), go figure
-      // http://stackoverflow.com/questions/21994261/gettext-not-working-on-a-select-from-dropdown
-
-      // TODO: figure out how to deal with multiple Uppy instances on the page
-      return driver.findElement({css: '.UppyDragDrop-One-Progress .UppyProgressBar-percentage'})
-        .getAttribute('textContent')
-        .then(function (value) {
-          var progress = parseInt(value)
-          var isFileUploaded = progress === 100
-          return isFileUploaded
-        })
-    }
-
-    driver.wait(isUploaded, 12000, 'File image.jpg should be uploaded within 15 seconds')
-      .then(function (result) {
-        tools.testEqual(driver, t, result)
-        driver.quit()
-      })
-      .catch(function (err) {
-        tools.collectErrors(driver).then(function () {
-          tools.testFail(driver, t, err)
-          driver.quit()
-        })
-      })
-  })
-}

+ 0 - 21
test/acceptance/dummy.spec.js

@@ -1,21 +0,0 @@
-var test = require('tape')
-var webdriver = require('selenium-webdriver')
-
-var driver = new webdriver
-  .Builder()
-  .forBrowser('firefox')
-  .build()
-
-test('open a page, create a variable and get its value', function (t) {
-  t.plan(1)
-
-  driver.get('http://ya.ru')
-  driver.executeScript('window.a = "blabla";')
-  driver.sleep(2000)
-  driver.executeScript('return a').then(function (val) {
-    console.log(val)
-    t.equal(val, 'blabla')
-  })
-  driver.sleep(5000)
-  driver.quit()
-})

+ 0 - 49
test/acceptance/fallback.spec.js

@@ -1,49 +0,0 @@
-var test = require('tape')
-var path = require('path')
-var tools = require('./tools')
-
-module.exports = function (driver, platform, host) {
-  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'
-
-  test(tools.prettyTestName(testName, platform), function (t) {
-    t.plan(1)
-
-    driver.get(host + '/examples/multipart/index.html')
-
-    driver.manage().window().maximize()
-
-    tools.setSauceTestName(driver, testName)
-
-    driver
-      .findElement({css: '.UppyForm input'})
-      .sendKeys(path.join(__dirname, 'image.jpg'))
-
-    // driver.switchTo().alert().dismiss()
-    //   .catch(function (err) {
-    //     console.log(err)
-    //   })
-    driver.findElement({css: '.UppyForm button'}).click()
-
-    function isRedirectedAfterUpload () {
-      // this should close the “Do you want to save this file?” alert when Travis runs the test
-
-      return driver.getCurrentUrl().then(function (val) {
-        console.log('current url is ', val)
-        var isPageRedirected = val.indexOf('api2.transloadit.com') !== -1
-        return isPageRedirected
-      })
-    }
-
-    driver.wait(isRedirectedAfterUpload, 12000, 'Browser should navigate to api2.transloadit.com after upload')
-      .then(function (isPageRedirected) {
-        tools.testEqual(driver, t, isPageRedirected === true)
-        driver.quit()
-      })
-      .catch(function (err) {
-        tools.collectErrors(driver).then(function () {
-          tools.testFail(driver, t, err)
-          driver.quit()
-        })
-      })
-  })
-}

+ 0 - 40
test/acceptance/i18n.spec.js

@@ -1,40 +0,0 @@
-var test = require('tape')
-var tools = require('./tools')
-
-module.exports = function (driver, platform, host) {
-  var testName = 'i18n: load DragDrop with Russian localization strings'
-
-  test(tools.prettyTestName(testName, platform), function (t) {
-    t.plan(1)
-
-    driver.get(host + '/examples/i18n')
-    driver.manage().window().maximize()
-
-    tools.setSauceTestName(driver, testName)
-
-    function findLabelTextElement () {
-      return driver.findElements({css: '.uppy-DragDrop-label'}).then(function (result) {
-        return result[0]
-      })
-    }
-
-    driver.wait(findLabelTextElement, 8000, 'Uppy should load within 8 seconds')
-      .then(function (element) {
-        element.getText().then(function (value) {
-          // why trim? Microsoft Edge:
-          // expected: 'Выберите файл или перенесите его сюда'
-          // actual:   'Выберите файл или перенесите его сюда '
-          var expectedValue = 'Перенесите файлы сюда или выберите'
-          console.log(value, '/', expectedValue)
-          tools.testEqual(driver, t, value.trim() === expectedValue)
-          driver.quit()
-        })
-      })
-      .catch(function (err) {
-        tools.collectErrors(driver).then(function () {
-          tools.testFail(driver, t, err)
-          driver.quit()
-        })
-      })
-  })
-}

BIN
test/acceptance/image.jpg


BIN
test/acceptance/image2.jpg


+ 0 - 135
test/acceptance/index.js

@@ -1,135 +0,0 @@
-// Docs aren't that great to find. Mostly JAVA based. Here are few helpful resources:
-// - https://www.browserstack.com/automate/node#testing-frameworks
-// - http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/index_exports_Driver.html
-// - https://github.com/SeleniumHQ/selenium/blob/8f988e07cc316a48e0ff94d8ff823c95142532e9/javascript/webdriver/webdriver.js
-// - https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/test/upload_test.js
-//
-// - https://github.com/SeleniumHQ/selenium/wiki/WebDriverJs
-// - http://seleniumhq.github.io/selenium/docs/api/javascript/
-// - http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/index.html
-// - http://selenium.googlecode.com/git/docs/api/javascript/namespace_webdriver_By.html
-// - http://selenium.googlecode.com/git/docs/api/javascript/class_webdriver_WebElement.html
-
-// require('babel-register')
-
-var webdriver = require('selenium-webdriver')
-var remote = require('selenium-webdriver/remote')
-
-// The Travis Sauce Connect addon exports the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables,
-// and relays connections to the hub URL back to Sauce Labs.
-// See: https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-Sauce-Labs
-var username = process.env.SAUCE_USERNAME
-var accessKey = process.env.SAUCE_ACCESS_KEY
-
-var remoteHost = 'http://uppy.io'
-var localHost = 'http://localhost:4000'
-
-// if accessKey is supplied as env variable, this is a remote Saucelabs test
-var isTravisTest = process.env.TRAVIS === 'true'
-var isRemoteTest = !!accessKey
-
-var host = localHost
-if (isTravisTest) {
-  // @todo This should become localhost to utilize the Travis saucelabs addon tunnel
-  // But it seems Edge and Safari fail on that right now, so targeting uppy.io instead.
-  // That is unideal, as we are then testing a previous deploy, and not the current build
-  // host = remoteHost
-  host = localHost
-} else if (isRemoteTest) {
-  // We're not too sure about a working tunnel otherwise, best just test uppy.io
-  host = remoteHost
-} else {
-  // If we don't have any access keys set, we'll assume you'll be playing around with a local
-  // firefox webdriver.
-  host = localHost
-}
-
-console.log('Acceptance tests will be targetting: ' + host)
-
-var platforms = [
-  // { browser: 'Safari', version: '8.0', os: 'OS X 10.10' }
-  // { browser: 'MicrosoftEdge', version: '13.10586', os: 'Windows 10' },
-  { browser: 'Firefox', version: '38.0', os: 'Linux' },
-  { browser: 'Internet Explorer', version: '10.0', os: 'Windows 8' },
-  { browser: 'Internet Explorer', version: '11.103', os: 'Windows 10' },
-  { browser: 'Chrome', version: '48.0', os: 'Windows 7' },
-  { browser: 'Firefox', version: '34.0', os: 'Windows 7' }
-]
-
-var tests = [
-  require('./multipart.spec.js'),
-  require('./i18n.spec.js'),
-  require('./dragdrop.spec.js')
-]
-
-function buildDriver (platform) {
-  var driver
-  if (isRemoteTest) {
-    var capabilities = {
-      'browserName': platform.browser,
-      'platform': platform.os,
-      'version': platform.version,
-      'username': username,
-      'accessKey': accessKey
-    }
-
-    if (isTravisTest) {
-      // @todo Do we need a hub_url = "%s:%s@localhost:4445" % (username, access_key)
-      // as mentioned in https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-Sauce-Labs ?
-      capabilities['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER
-      capabilities['build'] = process.env.TRAVIS_BUILD_NUMBER
-      capabilities['name'] = 'Travis ##' + process.env.TRAVIS_JOB_NUMBER
-      capabilities['tags'] = [process.env.TRAVIS_NODE_VERSION, 'CI']
-    }
-
-    driver = new webdriver
-      .Builder()
-      .withCapabilities(capabilities)
-      .usingServer('http://' + username + ':' + accessKey +
-                   '@ondemand.saucelabs.com:80/wd/hub')
-      .build()
-    driver.setFileDetector(new remote.FileDetector())
-  } else {
-    driver = new webdriver
-      .Builder()
-      .forBrowser('firefox')
-      .build()
-  }
-  return driver
-}
-
-var specificTests = {
-  fallback: function () {
-    var ancientPlatform = { browser: 'internet explorer', version: '8.0', os: 'Windows 7' }
-    var driver = buildDriver({ browser: 'internet explorer', version: '8.0', os: 'Windows 7' })
-    var test = require('./fallback.spec.js')
-
-    test(driver, ancientPlatform, host)
-  }
-}
-// RUN TESTS
-
-function runAllTests () {
-  if (isRemoteTest) {
-    // run custom platform-specific tests here
-    // <form> fallback test
-    console.log('Skipping the fallback test', specificTests.fallback)
-    // specificTests.fallback()
-
-    // run all tests for all platforms
-    platforms.forEach(function (platform) {
-      tests.forEach(function (test) {
-        var driver = buildDriver(platform)
-        test(driver, platform, host)
-      })
-    })
-  } else {
-    // run tests just for local Firefox
-    tests.forEach(function (test) {
-      var driver = buildDriver()
-      test(driver, { browser: 'Firefox', version: 'Version', os: 'Local' }, host)
-    })
-  }
-}
-
-runAllTests()

+ 0 - 65
test/acceptance/multipart.spec.js

@@ -1,65 +0,0 @@
-var test = require('tape')
-var tools = require('./tools')
-var path = require('path')
-
-module.exports = function (driver, platform, host) {
-  var testName = 'Multipart: upload a file'
-
-  test(tools.prettyTestName(testName, platform), function (t) {
-    t.plan(1)
-
-    driver.get(host + '/examples/multipart/')
-    driver.manage().window().maximize()
-
-    tools.setSauceTestName(driver, testName)
-
-    // driver.manage().timeouts().implicitlyWait(5 * 1000)
-
-    var platformBrowser = platform.browser.toLowerCase()
-    if (platformBrowser === 'safari' || platformBrowser === 'microsoftedge') {
-      console.log('fake-selecting a fake file')
-      driver.executeScript(tools.uppySelectFakeFile)
-      // driver.findElement({css: '.UppyForm-uploadBtn'}).click()
-    } else {
-      console.log('selecting a real file')
-      driver.executeScript('document.querySelector(".uppy-FileInput-input").style.opacity = 1')
-      // Find input by css selector & pass absolute image path to it
-      driver.findElement({css: '.uppy-FileInput-input'})
-        .then(function (el) {
-          el.sendKeys(path.join(__dirname, 'image.jpg'))
-          // el.sendKeys(path.join(__dirname, 'image2.jpg'))
-          // driver.findElement({css: '.UppyForm-uploadBtn'}).click()
-        })
-        .catch(function (err) {
-          throw err
-        })
-    }
-
-    function isUploaded () {
-      // .getText() only works on visible elements, so we use .getAttribute('textContent'), go figure
-      // http://stackoverflow.com/questions/21994261/gettext-not-working-on-a-select-from-dropdown
-      return driver.findElement({css: '.UppyProgressBar .UppyProgressBar-percentage'})
-        .getAttribute('textContent')
-        .then(function (value) {
-          var progress = parseInt(value)
-          var isFileUploaded = progress === 100
-          return isFileUploaded
-        })
-        .catch(function (err) {
-          console.log(err)
-        })
-    }
-
-    driver.wait(isUploaded, 12000, 'File image.jpg should be uploaded within 15 seconds')
-      .then(function (result) {
-        tools.testEqual(driver, t, result)
-        driver.quit()
-      })
-      .catch(function (err) {
-        tools.collectErrors(driver).then(function () {
-          tools.testFail(driver, t, err)
-          driver.quit()
-        })
-      })
-  })
-}

+ 0 - 49
test/acceptance/saucelabs-dummy.spec.js

@@ -1,49 +0,0 @@
-var webdriver = require('selenium-webdriver')
-var remote = require('selenium-webdriver/remote')
-
-var username = process.env.SAUCE_USERNAME
-var accessKey = process.env.SAUCE_ACCESS_KEY
-
-// var platform = { browser: 'firefox', version: '34.0', os: 'Windows 7' }
-var platform = { browser: 'Safari', version: '9.0', os: 'OS X 10.11' }
-
-function buildDriver (platform) {
-  var driver = new webdriver
-    .Builder()
-    .withCapabilities({
-      'browserName': platform.browser,
-      'platform': platform.os,
-      'version': platform.version,
-      'username': username,
-      'accessKey': accessKey
-    })
-    .usingServer('http://' + username + ':' + accessKey +
-                '@ondemand.saucelabs.com:80/wd/hub')
-    .build()
-  driver.setFileDetector(new remote.FileDetector())
-  return driver
-}
-
-function getBtnValue () {
-  return document.querySelector('.button__text').textContent
-}
-
-function runTest (driver, platform) {
-  console.log('Running dummy test in ' + platform.browser + ' on ' + platform.os)
-  driver.executeScript('sauce:job-name=dummy test')
-
-  driver.get('http://ya.ru')
-  driver.executeScript(getBtnValue).then(function (val) {
-    console.log(val)
-    driver.getTitle().then(function (title) {
-      console.log('title is: ' + title)
-      console.log('Finnished running dummy test, I quit!')
-      driver
-        .executeScript('sauce:job-result=passed')
-      driver.quit()
-    })
-  })
-}
-
-var driver = buildDriver(platform)
-runTest(driver, platform)

+ 0 - 118
test/acceptance/tools.js

@@ -1,118 +0,0 @@
-var webdriver = require('selenium-webdriver')
-// var firefox = require('selenium-webdriver/firefox')
-var By = webdriver.By
-// var path = require('path')
-var chalk = require('chalk')
-
-function uppySelectFakeFile () {
-  var blob = new Blob(
-    ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='],
-    {type: 'image/svg+xml'}
-  )
-  window._uppy.addFile({
-    source: 'acceptance-test',
-    name: 'test-file',
-    type: 'image/svg+xml',
-    data: blob
-  })
-}
-
-function prettyTestName (name, platform) {
-  var testName = chalk.cyan.bold(name)
-  var platformName = chalk.yellow(
-        platform.os + ', ' +
-        platform.browser + ' ' +
-        platform.version
-      )
-  return testName + ' / ' + platformName
-}
-
-// https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+Selenium's+JavaScript+Executor
-function setSauceTestStatus (driver, passed) {
-  driver
-    .executeScript('sauce:job-result=' + passed)
-    .catch(function (err) {
-      console.log('local test, so this is ok: ' + err)
-    })
-}
-
-function setSauceTestName (driver, testName) {
-  driver
-    .executeScript('sauce:job-name=' + testName)
-    .catch(function (err) {
-      console.log('local test, so this is ok: ' + err)
-    })
-}
-
-function testEqual (driver, t, condition) {
-  t.equal(condition, true)
-  if (condition) {
-    setSauceTestStatus(driver, true)
-  } else {
-    setSauceTestStatus(driver, false)
-  }
-}
-
-function testFail (driver, t, err) {
-  t.fail(err)
-  setSauceTestStatus(driver, false)
-}
-
-// Monitor for errors, and dump them
-function collectErrors (driver) {
-  return driver.executeScript('return uppyLog;')
-    .then(function (uppyLog) {
-      console.error([
-        '[uppy-log]',
-        chalk.red(uppyLog)
-      ].join(' '))
-    })
-    .catch(function (err) {
-      console.log('no uppyLog, that’s fine: ' + err)
-    })
-
-    // TODO: maybe figure out a way to get errors from all browsers
-    // return driver.executeScript('return window.JSErrorCollector_errors.pump()')
-    //   .then(function (errors) {
-    //     if (!errors || !errors.length) {
-    //       return
-    //     }
-    //     errors.forEach(function (error) {
-    //       console.error([
-    //         '[browser-error]',
-    //         chalk.magenta(error.sourceName),
-    //         chalk.dim('#' + error.lineNumber),
-    //         chalk.red(error.errorMessage)
-    //       ].join(' '))
-    //     })
-    //     return
-    //   })
-}
-
-// function setDriver () {
-//   var profile = new firefox.Profile()
-//   // profile.addExtension(path.join(__dirname, 'xpi', 'firebug-2.0.16.xpi'))
-//   // profile.addExtension(path.join(__dirname, 'xpi', 'JSErrorCollector.xpi'))
-//   // profile.setPreference('extensions.firebug.showChromeErrors', true)
-//
-//   var options = new firefox.Options().setProfile(profile)
-//   var driver = new firefox.Driver(options)
-//
-//   // var driver = new webdriver.Builder()
-//   //     .forBrowser('firefox')
-//   //     .build()
-//
-//   return driver
-// }
-
-module.exports = {
-  // setDriver,
-  prettyTestName,
-  uppySelectFakeFile,
-  collectErrors,
-  testEqual,
-  testFail,
-  setSauceTestName,
-  setSauceTestStatus,
-  By
-}

BIN
test/acceptance/xpi/JSErrorCollector.xpi


BIN
test/acceptance/xpi/firebug-2.0.16.xpi