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 5 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;
exports.command = function(url, bundle = 'https://localhost:8443/loader.js', callback) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Now that you're using es6 everything, do you still need to create the exports object? Or can you just say:

export const command = function(...)

Also, while you're at it, can you use an arrow function here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed. Unfortunately we're unable to use an arrow function due to losing the ability to call 'argument.lengths'.

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)
}
});
});
});
};
})
})
})
}
12 changes: 6 additions & 6 deletions commands/triggerClick.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
exports.command = function(selector, callback) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same comment about exports here

var client = this;
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
Copy Markdown

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
Copy Markdown

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