diff --git a/cli/__snapshots__/download_spec.js b/cli/__snapshots__/download_spec.js index 35abbc69e6..0603417dbf 100644 --- a/cli/__snapshots__/download_spec.js +++ b/cli/__snapshots__/download_spec.js @@ -1,10 +1,18 @@ +exports['latest desktop url 1'] = ` +https://download.cypress.io/desktop?os=OS&arch=ARCH +` + +exports['specific version desktop url 1'] = ` +https://download.cypress.io/desktop/0.20.2?os=OS&arch=ARCH +` + exports['download status errors 1'] = ` Error: The Cypress App could not be downloaded. Please check network connectivity and try again: ---------- -URL: https://download.cypress.io/desktop?os=mac +URL: https://download.cypress.io/desktop?os=OS&arch=ARCH 404 - Not Found ---------- diff --git a/cli/__snapshots__/errors_spec.js b/cli/__snapshots__/errors_spec.js index 32f04a65ea..0dc839783d 100644 --- a/cli/__snapshots__/errors_spec.js +++ b/cli/__snapshots__/errors_spec.js @@ -1,11 +1,11 @@ exports['errors individual has the following errors 1'] = [ - 'missingXvfb', - 'missingApp', - 'missingDependency', - 'versionMismatch', - 'unexpected', - 'failedDownload', - 'failedUnzip', + "missingXvfb", + "missingApp", + "missingDependency", + "versionMismatch", + "unexpected", + "failedDownload", + "failedUnzip" ] exports['errors .errors.formErrorText returns fully formed text message 1'] = ` diff --git a/cli/__snapshots__/run_spec.js b/cli/__snapshots__/run_spec.js index f643337bac..47f5035860 100644 --- a/cli/__snapshots__/run_spec.js +++ b/cli/__snapshots__/run_spec.js @@ -1,22 +1,22 @@ exports['exec run .processRunOptions passes --browser option 1'] = [ - '--run-project', + "--run-project", null, - '--browser', - 'test browser', + "--browser", + "test browser" ] exports['exec run .processRunOptions passes --record option 1'] = [ - '--run-project', + "--run-project", null, - '--record', - 'my record id', + "--record", + "my record id" ] exports['exec run .processRunOptions does not remove --record option when using --browser 1'] = [ - '--run-project', + "--run-project", null, - '--record', - 'foo', - '--browser', - 'test browser', + "--record", + "foo", + "--browser", + "test browser" ] diff --git a/cli/lib/tasks/download.js b/cli/lib/tasks/download.js index 1600b0e7aa..001e251465 100644 --- a/cli/lib/tasks/download.js +++ b/cli/lib/tasks/download.js @@ -34,7 +34,10 @@ const getOs = () => { } const prepend = (urlPath) => { - return `${url.resolve(baseUrl, urlPath)}?os=${getOs()}` + const endpoint = url.resolve(baseUrl, urlPath) + const osName = getOs() + const arch = os.arch() + return `${endpoint}?os=${osName}&arch=${arch}` } const getUrl = (version) => { @@ -154,4 +157,5 @@ const start = (options) => { module.exports = { start, + getUrl, } diff --git a/cli/test/lib/tasks/download_spec.js b/cli/test/lib/tasks/download_spec.js index 32d964a45e..17b925c190 100644 --- a/cli/test/lib/tasks/download_spec.js +++ b/cli/test/lib/tasks/download_spec.js @@ -3,6 +3,8 @@ require('../../spec_helper') const os = require('os') const nock = require('nock') const snapshot = require('snap-shot-it') +const la = require('lazy-ass') +const is = require('check-more-types') const fs = require(`${lib}/fs`) const logger = require(`${lib}/logger`) @@ -33,6 +35,23 @@ describe('download', function () { stdout.restore() }) + context('download url', () => { + it('returns url', () => { + const url = download.getUrl() + la(is.url(url), url) + }) + + it('returns latest desktop url', () => { + const url = download.getUrl() + snapshot('latest desktop url', normalize(url)) + }) + + it('returns specific desktop version url', () => { + const url = download.getUrl('0.20.2') + snapshot('specific version desktop url', normalize(url)) + }) + }) + it('sets options.version to response x-version', function () { nock('https://aws.amazon.com') .get('/some.zip') diff --git a/cli/test/support/normalize.js b/cli/test/support/normalize.js index 7236817666..17ba02e161 100644 --- a/cli/test/support/normalize.js +++ b/cli/test/support/normalize.js @@ -2,6 +2,7 @@ const stripAnsi = require('strip-ansi') const excessWhitespaceRe = /(\s{3,})/ const datesRe = /(\d+:\d+:\d+)/g +const downloadQueryRe = /(\?os=(mac|linux64|win)&arch=(x64|ia32))/ module.exports = (str) => { // strip dates and ansi codes @@ -10,5 +11,6 @@ module.exports = (str) => { str .replace(datesRe, 'xx:xx:xx') .replace(excessWhitespaceRe, ' ') + .replace(downloadQueryRe, '?os=OS&arch=ARCH') ) }