|
@@ -1,89 +1,27 @@
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
var test = require('tape')
|
|
|
var path = require('path')
|
|
|
-var chalk = require('chalk')
|
|
|
-var webdriver = require('selenium-webdriver')
|
|
|
-var firefox = require('selenium-webdriver/firefox')
|
|
|
-var By = webdriver.By
|
|
|
-
|
|
|
-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 core = require('./core')
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-var hexoServer = 'http://localhost:4000'
|
|
|
+var config = {
|
|
|
+ i18nTestUrl: 'http://localhost:4000/examples/i18n',
|
|
|
+ dragDropLabelSelector: '.UppyDragDrop-label',
|
|
|
+ imageAbsolutePath: path.join(__dirname, 'image.jpg')
|
|
|
+}
|
|
|
|
|
|
test('make sure Uppy loads with Russian language pack', function (t) {
|
|
|
- driver.get(hexoServer + '/examples/i18n/')
|
|
|
-
|
|
|
-
|
|
|
- const promise = driver.executeScript('return window.JSErrorCollector_errors.pump()')
|
|
|
- promise.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(' '))
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- var consoleElement = driver.findElement(By.id('console-log'))
|
|
|
+ core.driver.get(config.i18nTestUrl)
|
|
|
|
|
|
-
|
|
|
- driver.wait(isLoaded.bind(this, consoleElement), 8000)
|
|
|
+
|
|
|
+ core.driver.sleep(3000)
|
|
|
|
|
|
- driver.findElement(By.css('.UppyDragDrop-label')).getText().then(function (val) {
|
|
|
- console.dir({val: val})
|
|
|
- t.equal(val, 'Выберите файл или перенесите его сюда')
|
|
|
- })
|
|
|
+ core.driver.findElement(core.By.css(config.dragDropLabelSelector))
|
|
|
+ .getText()
|
|
|
+ .then(function (val) {
|
|
|
+ console.dir({val: val})
|
|
|
+ t.equal(val, 'Выберите файл или перенесите его сюда')
|
|
|
+ })
|
|
|
|
|
|
- driver.quit()
|
|
|
+ core.driver.quit()
|
|
|
|
|
|
t.end()
|
|
|
-
|
|
|
-
|
|
|
- * Check if uploading is finished by looking for a result message
|
|
|
- * in the example's console output element.
|
|
|
- * @return {Boolean} If uploading is complete
|
|
|
- */
|
|
|
- function isLoaded (consoleElement) {
|
|
|
- return getElementValue(consoleElement)
|
|
|
- .then(function (value) {
|
|
|
- return value.indexOf('-->') !== -1
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * Get value attribute of element
|
|
|
- * @param {webdriver.WebElement} element Selenium element object
|
|
|
- * @return {webdriver.promise} Promise resolving to element value
|
|
|
- */
|
|
|
- function getElementValue (element) {
|
|
|
- return element.getAttribute('value')
|
|
|
- .then(function (value) {
|
|
|
- return value
|
|
|
- })
|
|
|
- }
|
|
|
})
|