Skip to content

Commit

Permalink
Merge pull request DevExpress#169 from inikulin/gh126
Browse files Browse the repository at this point in the history
Minor changes to the CLI API. Implement correct comparison of URLs in client browser code (fixes DevExpress#126)
  • Loading branch information
helen-dikareva committed Nov 9, 2015
2 parents b5bb7a4 + 2eca387 commit 28731c1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cli/argument-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class CliArgumentParser {

.option('-b, --list-browsers', 'output the available browser aliases')
.option('-r, --reporter <name>', 'specify the reporter type to use')
.option('-p, --report-path <path>', 'specify the path to which the report file should be saved')
.option('-p, --report-path <path>', 'send the report to a file at <path>')
.option('-s, --screenshots <path>', 'enable screenshot capturing and specify the path to save the screenshots to')
.option('-S, --screenshots-on-fails', 'take a screenshot whenever a test fails')
.option('-q, --quarantine-mode', 'enable the quarantine mode')
Expand All @@ -101,7 +101,7 @@ export default class CliArgumentParser {
.option('-F, --fixture-grep <pattern>', 'run only fixtures matching the specified pattern')
.option('--ports <port1,port2>', 'specify custom port numbers')
.option('--hostname <name>', 'specify the hostname')
.option('--qrcode', 'outputs QR-code that repeats URLs used to connect the remote browsers');
.option('--qr-code', 'outputs QR-code that repeats URLs used to connect the remote browsers');
}

_filterAndCountRemotes (browser) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function runTests (argParser) {
var port1 = opts.ports && opts.ports[0];
var port2 = opts.ports && opts.ports[1];
var testCafe = await createTestCafe(opts.hostname, port1, port2);
var remoteBrowsers = await createRemoteBrowserConnections(testCafe, argParser.remoteCount, opts.qrcode);
var remoteBrowsers = await createRemoteBrowserConnections(testCafe, argParser.remoteCount, opts.qrCode);
var browsers = argParser.browsers.concat(remoteBrowsers);
var runner = testCafe.createRunner();

Expand Down
7 changes: 5 additions & 2 deletions src/client/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function sendXHR (url, XMLHttpRequest) {
});
}

function isCurrentLocation (url) {
return document.location.href.toLowerCase() === url.toLowerCase();
}


//API
export function startHeartbeat (heartbeatUrl, XMLHttpRequest) {
Expand All @@ -38,8 +42,7 @@ export function startHeartbeat (heartbeatUrl, XMLHttpRequest) {
export function checkStatus (statusUrl, XMLHttpRequest) {
return sendXHR(statusUrl, XMLHttpRequest)
.then((res) => {
if (res.cmd === COMMAND.run ||
res.cmd === COMMAND.idle && document.location.toString() !== res.url)
if (res.cmd === COMMAND.run || res.cmd === COMMAND.idle && !isCurrentLocation(res.url))
document.location = res.url;

//NOTE: prepare to close the browser
Expand Down
4 changes: 2 additions & 2 deletions test/server/cli-argument-parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('CLI argument parser', function () {
});

it('Should parse command line arguments', function (done) {
parse('-r list -S -q -e --hostname myhost --qrcode ie test/server/data/file-list/file-1.js')
parse('-r list -S -q -e --hostname myhost --qr-code ie test/server/data/file-list/file-1.js')
.then(function (parser) {
expect(parser.browsers).eql(['ie']);
expect(parser.src).eql([path.resolve(process.cwd(), 'test/server/data/file-list/file-1.js')]);
Expand All @@ -280,7 +280,7 @@ describe('CLI argument parser', function () {
expect(parser.opts.screenshotsOnFails).to.be.ok;
expect(parser.opts.quarantineMode).to.be.ok;
expect(parser.opts.skipJsErrors).to.be.ok;
expect(parser.opts.qrcode).to.be.ok;
expect(parser.opts.qrCode).to.be.ok;
done();
})
.catch(done);
Expand Down

0 comments on commit 28731c1

Please sign in to comment.