Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- './node_modules/mobify-code-style/es6/mobify-es6-react-a11y.yml'
33 changes: 16 additions & 17 deletions commands/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@
* @api commands
*/

var qs = require('querystring');
import qs from 'querystring'

exports.command = function(url, bundle, callback) {
var browser = this;
export const command = function(url, bundle = 'https://localhost:8443/loader.js', callback) {
const browser = this

if (arguments.length < 2) {
throw new Error('Usage: browser.preview(url, bundle, callback)');
throw new Error('Usage: browser.preview(url, bundle, callback)')
}

if (typeof bundle === 'function') {
callback = bundle;
bundle = null;
callback = bundle
bundle = null
}

var bundleUrl = bundle || 'https://localhost:8443/loader.js';
const params = qs.stringify({url, site_folder: bundle})

var params = qs.stringify({'url': url, 'site_folder': bundleUrl});

return browser.url('https://preview.mobify.com?' + params)
return browser
.url(`https://preview.mobify.com?${params}`)
.waitForElementPresent('#authorize', 10000, function() {
this.click('#authorize', function() {
browser.waitUntilMobified(10000, function(result) {
this.click('#authorize', () => {
browser.waitUntilMobified(10000, (result) => {
if (typeof callback === 'function') {
callback.call(browser, result);
callback.call(browser, result)
}
});
});
});
};
})
})
})
}
14 changes: 7 additions & 7 deletions commands/triggerClick.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
exports.command = function(selector, callback) {
var client = this;
export const command = function(selector, callback) {
const client = this
/*
/ Use Javascript's click when Selenium's does not register.
*/
client.execute('document.querySelector("' + selector + '").click();', function(result) {
client.execute(`document.querySelector("${selector}").click();`, (result) => {
if (typeof callback === 'function') {
callback.call(client, result);
callback.call(client, result)
}
});
})

return this;
};
return this
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"url": "https://github.com/mobify/nightwatch-commands/issues"
},
"devDependencies": {
"eslint": "3.19.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.10.3",
"nightwatch": "0.9.8",
"nodeunit": "0.8.4",
"grunt": "0.4.5",
Expand All @@ -20,7 +24,9 @@
},
"scripts": {
"install": "node selenium/install.js",
"test": "./node_modules/.bin/grunt lint; ./node_modules/.bin/grunt test"
"test": "./node_modules/.bin/grunt lint; ./node_modules/.bin/grunt test",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ; or &&? I don't actually remember what ; does 😅

"lint": "npm run lint:js",
"lint:js": "eslint '**/*.{js,jsx}'"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to double check that this blob works on Windows. I've run into issues with commands before where the quotes used for this mattered to Windows and broke things. 😞

},
"homepage": "https://github.com/mobify/nightwatch-commands",
"dependencies": {
Expand Down