Skip to content

Commit

Permalink
Merge branch 'develop' into fix/file-opener-zindex
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart committed Apr 6, 2021
2 parents c277c80 + 3ddd852 commit b8d70f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
4 changes: 3 additions & 1 deletion packages/server/lib/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const pkg = require('@packages/root')
const { agent } = require('@packages/network')
const konfig = require('./konfig')
const { machineId } = require('./util/machine_id')

const _getManifest = ({ id, initialLaunch, testingType }) => {
const url = konfig('desktop_manifest_url')

Expand All @@ -14,8 +15,9 @@ const _getManifest = ({ id, initialLaunch, testingType }) => {
headers: {
'x-cypress-version': pkg.version,
'x-os-name': os.platform(),
'x-arch': os.arch(),
'x-machine-id': id,
'x-initial-launch:': String(initialLaunch),
'x-initial-launch': String(initialLaunch),
'x-testing-type': testingType,
},
agent,
Expand Down
46 changes: 31 additions & 15 deletions packages/server/test/unit/updater_spec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
require('../spec_helper')

const machineId = require(`${root}lib/util/machine_id`)
const os = require('os')
const rp = require('@cypress/request-promise')
const Updater = require(`${root}lib/updater`)
const pkg = require('@packages/root')
const machineId = require(`${root}lib/util/machine_id`)
const Updater = require(`${root}lib/updater`)

describe('lib/updater', () => {
context('_getManifest', () => {
it('sends the right headers', () => {
sinon.stub(rp, 'get').resolves({})
context('._getManifest', () => {
const BASE_URL = 'https://download.cypress.io'

Updater._getManifest({ testingType: 'type', initialLaunch: true, id: 'machine-id' })
beforeEach(function () {
nock.cleanAll()

nock.enableNetConnect()
})

it('sends the right headers', () => {
sinon.stub(os, 'platform').returns('win32')
sinon.stub(os, 'arch').returns('x32')

nock(BASE_URL)
.matchHeader('x-cypress-version', pkg.version)
.matchHeader('x-os-name', 'win32')
.matchHeader('x-arch', 'x32')
.matchHeader('x-machine-id', 'machine-id')
.matchHeader('x-initial-launch', 'true')
.matchHeader('x-testing-type', 'type')
.get('/desktop.json')
.reply(200, {
version: '1000.0.0',
})

expect(rp.get).to.be.calledWithMatch({
headers: {
'x-cypress-version': pkg.version,
'x-os-name': 'linux',
'x-machine-id': 'machine-id',
'x-initial-launch:': 'true',
'x-testing-type': 'type',
},
return Updater
._getManifest({ testingType: 'type', initialLaunch: true, id: 'machine-id' })
.then((resp) => {
expect(resp.version).to.eq('1000.0.0')
})
})
})

context('check', () => {
context('.check', () => {
const version = pkg.version

beforeEach(() => {
Expand Down

0 comments on commit b8d70f7

Please sign in to comment.