cli: verify against installed version not package version when displaying first time opening message

This commit is contained in:
Brian Mann
2017-09-16 19:21:00 -04:00
parent 88b19a91e1
commit 2b415cab4c
3 changed files with 46 additions and 10 deletions
+14 -1
View File
@@ -12,7 +12,7 @@ Cypress Version: 1.2.3
`
exports['warning installed version does not match package version 1'] = `
exports['warning installed version does not match verified version 1'] = `
Installed version bloop does not match the expected package version 1.2.3
Note: there is no guarantee these versions will work properly together.
@@ -85,6 +85,19 @@ Opening Cypress...
`
exports['current version has not been verified 2'] = `
Installed version 9.8.7 does not match the expected package version 1.2.3
Note: there is no guarantee these versions will work properly together.
It looks like this is your first time using Cypress: 9.8.7
✔ Verified Cypress! /path/to/executable/dir
Opening Cypress...
`
exports['no welcome message 1'] = `
It looks like this is your first time using Cypress: 1.2.3
+4 -6
View File
@@ -179,20 +179,18 @@ function testBinary (version) {
return tasks.run()
}
const maybeVerify = (options = {}) => {
const maybeVerify = (installedVersion, options = {}) => {
return info.getVerifiedVersion()
.then((verifiedVersion) => {
const packageVersion = util.pkgVersion()
debug('has verified version', verifiedVersion)
// verify if packageVersion and verifiedVersion are different
const shouldVerify = options.force || differentFrom(packageVersion, verifiedVersion)
const shouldVerify = options.force || differentFrom(installedVersion, verifiedVersion)
debug('run verification check?', shouldVerify)
if (shouldVerify) {
return testBinary(packageVersion)
return testBinary(installedVersion)
.then(() => {
if (options.welcomeMessage) {
logger.log()
@@ -238,7 +236,7 @@ const start = (options = {}) => {
logger.log()
}
return maybeVerify(options)
return maybeVerify(installedVersion, options)
})
.catch((err) => {
if (err.known) {
+28 -3
View File
@@ -117,7 +117,7 @@ context('.verify', function () {
})
})
it('logs warning when installed version does not match package version', function () {
it('logs warning when installed version does not match verified version', function () {
const ctx = this
this.sandbox.stub(fs, 'statAsync')
@@ -137,7 +137,7 @@ context('.verify', function () {
})
.catch(() => {
snapshot(
'warning installed version does not match package version',
'warning installed version does not match verified version',
normalize(ctx.stdout.toString())
)
})
@@ -282,7 +282,32 @@ context('.verify', function () {
})
})
it('turns off Opening Cypres...', function () {
it('logs and runs when installed version is different than verified version', function () {
const ctx = this
return info.writeInfoFileContents({
version: '9.8.7',
verifiedVersion: packageVersion,
})
.then(() => {
return verify.start()
})
.then(() => {
return info.getVerifiedVersion()
})
.then((vv) => {
expect(vv).to.eq('9.8.7')
})
.delay(100) // give a little padding for listr
.then(() => {
snapshot(
'current version has not been verified',
normalize(ctx.stdout.toString())
)
})
})
it('turns off Opening Cypress...', function () {
const ctx = this
return info.writeInfoFileContents({