Skip to content

Commit

Permalink
Add workflow commands
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Mar 23, 2018
1 parent 883ae11 commit 3d3b6a5
Show file tree
Hide file tree
Showing 16 changed files with 3,844 additions and 2,482 deletions.
54 changes: 54 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,54 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"globals": {
"SS": true,
"expect": true,
"chunk": true,
"test": true,
"sinon": true,
"CONF": true,
"beforeChunk": true,
"afterChunk": true,
"fxXvfb": true,
"after": true,
"before": true,
"scope": true,
"rewire": true,
"fxWebdriver": true,
"fxVideo": true,
"fxKillWebdriver": true,
"fxBrowser": true,
"fxSelenium": true,
"document": true,
"window": true,
"html2canvas": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"rules": {
"no-console": 0,
"no-extra-semi": 0,
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
};
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
node_modules
*.log
.nyc_output
7 changes: 2 additions & 5 deletions .travis.yml
Expand Up @@ -3,10 +3,7 @@ node_js:
- "8"

install:
- npm install

before_script:
- npm install -g gulp-cli
- npm i

script:
- gulp test-unit
- npm run ci
54 changes: 0 additions & 54 deletions gulpfile.js

This file was deleted.

16 changes: 5 additions & 11 deletions lib/config.js
Expand Up @@ -13,14 +13,8 @@
* @prop {object} webdriver - Webdriver options.
*/

var fs = require("fs");
var path = require("path");

var expect = require("chai").expect;
var fse = require("fs-extra");

var U = require("glace-utils");
var LOG = U.logger;

var config = U.config;
var args = config.args;
Expand All @@ -42,13 +36,13 @@ config.chrome = U.defVal(config.chrome, {});
config.chrome.incognito = U.defVal(args.chromeIncognito, false);

expect(["pc", "android", "ios"],
"Invalid `--platform` value").include(config.web.platform);
"Invalid `--platform` value").include(config.web.platform);
config.web.browser = U.defVal(args.browser);

var desired = config.webdriver.desiredCapabilities = {};

if (args.seleniumAddress) {
var [ host, port ] = args.seleniumAddress.split(':');
var [ host, port ] = args.seleniumAddress.split(":");
if (host) config.webdriver.host = host;
if (port) config.webdriver.port = port;
};
Expand All @@ -59,9 +53,9 @@ if (config.web.platform === "pc") {
if (desired.browserName === "chrome") {
desired.chromeOptions = {
args: [ "test-type",
"start-maximized",
"disable-infobars",
"enable-precise-memory-info" ],
"start-maximized",
"disable-infobars",
"enable-precise-memory-info" ],
prefs: {
"credentials_enable_service": false,
"profile": {
Expand Down
4 changes: 2 additions & 2 deletions lib/pluginHelp.js
Expand Up @@ -35,14 +35,14 @@ module.exports = (args, d) => {
},
"platform": {
describe: d("Specify platform type where tests will be executed.",
"Default is 'pc'."),
"Default is 'pc'."),
type: "string",
choices: [ "pc", "android", "ios" ],
group: "Selenium:",
},
"browser": {
describe: d("Name of browser where web tests will be",
"executed. Default value is platform specific."),
"executed. Default value is platform specific."),
type: "string",
group: "Selenium:",
},
Expand Down
8 changes: 4 additions & 4 deletions lib/pom/element.js
Expand Up @@ -192,7 +192,7 @@ Element.prototype.isExist = function () {
* @throws {TimeoutError} If control doesn't exist after timeout.
*/
Element.prototype.waitForExist = function (timeout) {
var timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
var errMsg = `${this.name} (${this.selector}) doesn't exist after ${timeout}s`;

return this._getDriver().waitUntil(async () => {
Expand All @@ -209,7 +209,7 @@ Element.prototype.waitForExist = function (timeout) {
* @throws {TimeoutError} If control is still exist after timeout.
*/
Element.prototype.waitForNonExist = function (timeout) {
var timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
var errMsg = `${this.name} (${this.selector}) still exists after ${timeout}s`;

return this._getDriver().waitUntil(async () => {
Expand Down Expand Up @@ -238,7 +238,7 @@ Element.prototype.isVisible = function () {
* @throws {TimeoutError} If control isn't visible after timeout.
*/
Element.prototype.waitForVisible = function (timeout) {
var timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
var errMsg = `${this.name} (${this.selector}) isn't visible ` +
`after ${timeout}s`;

Expand All @@ -256,7 +256,7 @@ Element.prototype.waitForVisible = function (timeout) {
* @throws {TimeoutError} If control is still visible after timeout.
*/
Element.prototype.waitForInvisible = function (timeout) {
var timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
timeout = U.defVal(timeout, CONF.web.uiTimeout) * 1000;
var errMsg = `${this.name} (${this.selector}) is still visible after ${timeout}s`;

return this._getDriver().waitUntil(async () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/pom/index.js
Expand Up @@ -40,7 +40,7 @@ Page.prototype.setDriver = function (webdriver) {
*/
Page.prototype.getDriver = function () {
expect(this._webdriver,
"Webdriver isn't set")
"Webdriver isn't set")
.to.exist;
return this._webdriver;
};
Expand Down Expand Up @@ -87,7 +87,7 @@ Page.prototype._addElement = function (name, selector) {
};
this[name] = new Element(name, selector, this);
} else {
throw new Error(`selector should be string or array or function ` +
throw new Error("selector should be string or array or function " +
`but not ${typeof selector}`);
};
};
Expand Down
23 changes: 12 additions & 11 deletions lib/steps/browser.js
Expand Up @@ -84,7 +84,7 @@ var BrowserSteps = {
LOG.debug(
`Selenium server starts with PID ${child.pid}`);
resolve(child);
})
});
});
return true;
},
Expand All @@ -110,8 +110,8 @@ var BrowserSteps = {
await new Promise((resolve, reject) => {

this._seleniumProc.on("exit", (code, signal) => {
LOG.debug(`Selenium server was stopped with`,
`code ${code} and signal ${signal}`);
LOG.debug("Selenium server was stopped with",
`code ${code} and signal ${signal}`);
delete this._seleniumProc;
resolve();
});
Expand Down Expand Up @@ -146,6 +146,7 @@ var BrowserSteps = {

opts = U.defVal(opts, {});
var check = U.defVal(opts.check, true);
var opt;

if (CONF.web.platform === "pc" &&
this.webdriver.desiredCapabilities.browserName === "chrome") {
Expand All @@ -163,12 +164,12 @@ var BrowserSteps = {
`proxy-server=${U.hostname}:${CONF.proxy.globalPort}`,
`proxy-bypass-list=localhost,127.0.0.1,${U.hostname}`,
];
for (var opt of proxyOptions) {
for (opt of proxyOptions) {
if (!isOptPresent(opt, chromeOpts)) chromeOpts.push(opt);
};
};

for (var opt of defChromeOpts) {
for (opt of defChromeOpts) {
if (!isOptPresent(opt, chromeOpts)) chromeOpts.push(opt);
};

Expand All @@ -179,7 +180,7 @@ var BrowserSteps = {

if (check) {
expect(await this.webdriver.session(),
"Browser wasn't launched").to.exist;
"Browser wasn't launched").to.exist;
};

if (CONF.web.width && CONF.web.height && CONF.web.platform === "pc") {
Expand Down Expand Up @@ -223,10 +224,10 @@ var BrowserSteps = {
var viewport = await this.webdriver.getViewportSize();

expect(viewport.width,
"Invalid browser viewport width")
"Invalid browser viewport width")
.to.be.equal(width);
expect(viewport.height,
"Invalid browser viewport height")
"Invalid browser viewport height")
.to.be.equal(height);
};

Expand Down Expand Up @@ -261,7 +262,7 @@ var BrowserSteps = {

if (opts.check) {
expect(await this.webdriver.session(),
"Browser wasn't closed").to.not.exist;
"Browser wasn't closed").to.not.exist;
};
this._isBrowserLaunched = false;
return true;
Expand Down Expand Up @@ -313,7 +314,7 @@ var BrowserSteps = {
await this.webdriver.waitUntil(async () => {
var curUrl = await this.webdriver.getUrl();
LOG.debug(`Compare current URL ${curUrl}`,
`with expected ${webUrl}`);
`with expected ${webUrl}`);
return curUrl.startsWith(webUrl);
}, timeout, errMsg);
};
Expand All @@ -333,7 +334,7 @@ var BrowserSteps = {
*/

expect(this.webUrl,
"Web URL isn't defined").to.exist;
"Web URL isn't defined").to.exist;
await this.openUrl(this.webUrl, opts);
},
};
Expand Down
4 changes: 2 additions & 2 deletions lib/steps/index.js
Expand Up @@ -15,7 +15,7 @@ require("../fixtures");

var WebSteps = {};
_.extend(WebSteps,
require("./browser"),
require("./page"));
require("./browser"),
require("./page"));

module.exports = WebSteps;
2 changes: 1 addition & 1 deletion lib/steps/page.js
Expand Up @@ -66,7 +66,7 @@ var PageSteps = {
*/

expect(this.webUrl,
"Web URL isn't defined").to.exist;
"Web URL isn't defined").to.exist;
var page = this._pages()[pageName];
var webUrl = url.resolve(this.webUrl, page.url);
await this.openUrl(webUrl);
Expand Down

0 comments on commit 3d3b6a5

Please sign in to comment.