-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: capture versions of relevant dependencies with `x-dependencies…
…` header (#26814)
- Loading branch information
Showing
7 changed files
with
255 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ describe('VersionsDataSource', () => { | |
context('.versions', () => { | ||
let ctx: DataContext | ||
let fetchStub: sinon.SinonStub | ||
let isDependencyInstalledStub: sinon.SinonStub | ||
let isDependencyInstalledByNameStub: sinon.SinonStub | ||
let mockNow: Date = new Date() | ||
let versionsDataSource: VersionsDataSource | ||
let currentCypressVersion: string = pkg.version | ||
|
@@ -36,12 +36,12 @@ describe('VersionsDataSource', () => { | |
ctx.coreData.currentTestingType = 'e2e' | ||
|
||
fetchStub = sinon.stub() | ||
isDependencyInstalledStub = sinon.stub() | ||
isDependencyInstalledByNameStub = sinon.stub() | ||
}) | ||
|
||
beforeEach(() => { | ||
sinon.stub(ctx.util, 'fetch').callsFake(fetchStub) | ||
sinon.stub(ctx.util, 'isDependencyInstalled').callsFake(isDependencyInstalledStub) | ||
sinon.stub(ctx.util, 'isDependencyInstalledByName').callsFake(isDependencyInstalledByNameStub) | ||
sinon.stub(os, 'platform').returns('darwin') | ||
sinon.stub(os, 'arch').returns('x64') | ||
sinon.useFakeTimers({ now: mockNow }) | ||
|
@@ -194,31 +194,41 @@ describe('VersionsDataSource', () => { | |
}) | ||
|
||
it('generates x-framework, x-bundler, and x-dependencies headers', async () => { | ||
isDependencyInstalledStub.callsFake(async (dependency) => { | ||
isDependencyInstalledByNameStub.callsFake(async (packageName) => { | ||
// Should include any resolved dependency with a valid version | ||
if (dependency.package === 'react') { | ||
if (packageName === 'react') { | ||
return { | ||
dependency, | ||
dependency: packageName, | ||
detectedVersion: '1.2.3', | ||
satisfied: true, | ||
} as Cypress.DependencyToInstall | ||
} | ||
|
||
// Not satisfied dependency should be excluded | ||
if (dependency.package === 'vue') { | ||
if (packageName === 'vue') { | ||
return { | ||
dependency, | ||
dependency: packageName, | ||
detectedVersion: '4.5.6', | ||
satisfied: false, | ||
} | ||
} | ||
|
||
// Satisfied dependency without resolved version should result in -1 | ||
if (dependency.package === 'typescript') { | ||
if (packageName === '@builder.io/qwik') { | ||
return { | ||
dependency, | ||
dependency: packageName, | ||
detectedVersion: '1.1.4', | ||
} | ||
} | ||
|
||
if (packageName === '@playwright/experimental-ct-core') { | ||
return { | ||
dependency: packageName, | ||
detectedVersion: '1.33.0', | ||
} | ||
} | ||
|
||
// Dependency without resolved version should be excluded | ||
if (packageName === 'typescript') { | ||
return { | ||
dependency: packageName, | ||
detectedVersion: null, | ||
satisfied: true, | ||
} | ||
} | ||
|
||
|
@@ -238,7 +248,7 @@ describe('VersionsDataSource', () => { | |
headers: sinon.match({ | ||
'x-framework': 'react', | ||
'x-dev-server': 'vite', | ||
'x-dependencies': 'typescript@-1,react@1', | ||
'x-dependencies': '[email protected],[email protected],@builder.io/[email protected],@playwright/[email protected]', | ||
}), | ||
}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,30 @@ describe('Launchpad: Open Mode', () => { | |
cy.openProject('todos', ['--e2e']) | ||
}) | ||
|
||
it('includes `x-framework`, `x-dev-server`, and `x-dependencies` headers, even when launched in e2e mode', () => { | ||
it('includes `x-framework`, `x-dev-server`, and `x-dependencies` headers, even when launched in e2e mode if this is the initial launch of Cypress', () => { | ||
cy.withCtx((ctx) => { | ||
ctx.versions['_initialLaunch'] = true | ||
}) | ||
|
||
cy.visitLaunchpad() | ||
cy.skipWelcome() | ||
cy.get('h1').should('contain', 'Choose a browser') | ||
cy.withCtx((ctx, o) => { | ||
expect(ctx.util.fetch).to.have.been.calledWithMatch('https://download.cypress.io/desktop.json', { | ||
headers: { | ||
'x-framework': 'react', | ||
'x-dev-server': 'webpack', | ||
'x-dependencies': '[email protected]', | ||
}, | ||
}) | ||
}) | ||
}) | ||
|
||
it('does not include `x-dependencies` header, if this is not the initial launch of Cypress', () => { | ||
cy.withCtx((ctx) => { | ||
ctx.versions['_initialLaunch'] = false | ||
}) | ||
|
||
cy.visitLaunchpad() | ||
cy.skipWelcome() | ||
cy.get('h1').should('contain', 'Choose a browser') | ||
|
@@ -74,7 +97,6 @@ describe('Launchpad: Open Mode', () => { | |
headers: { | ||
'x-framework': 'react', | ||
'x-dev-server': 'webpack', | ||
'x-dependencies': 'typescript@4', | ||
}, | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6df7a70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
6df7a70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
6df7a70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
6df7a70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
6df7a70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: