Skip to content

Commit

Permalink
feat: Add login state to manifest request for analytics (#22791)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-plummer committed Jul 19, 2022
1 parent 2def224 commit 36278fc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/data-context/src/sources/VersionsDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class VersionsDataSource {
'x-os-name': os.platform(),
'x-arch': os.arch(),
'x-initial-launch': String(this._initialLaunch),
'x-logged-in': String(!!this.ctx.user),
}

if (this._currentTestingType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('VersionsDataSource', () => {
'x-initial-launch': String(true),
'x-machine-id': 'abcd123',
'x-testing-type': 'e2e',
'x-logged-in': 'false',
},
}).resolves({
json: sinon.stub().resolves({
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('VersionsDataSource', () => {
'x-arch': 'x64',
'x-initial-launch': String(false),
'x-testing-type': 'component',
'x-logged-in': 'false',
},
}).resolves({
json: sinon.stub().resolves({
Expand Down Expand Up @@ -136,6 +138,7 @@ describe('VersionsDataSource', () => {
'x-initial-launch': String(true),
'x-machine-id': 'abcd123',
'x-testing-type': 'e2e',
'x-logged-in': 'false',
},
})
.rejects()
Expand All @@ -162,6 +165,7 @@ describe('VersionsDataSource', () => {
'x-initial-launch': String(true),
'x-machine-id': 'abcd123',
'x-testing-type': 'e2e',
'x-logged-in': 'false',
},
})
.callsFake(async () => new Response('Error'))
Expand Down
58 changes: 45 additions & 13 deletions packages/launchpad/cypress/e2e/open-mode.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,53 @@ describe('Launchpad: Open Mode', () => {
cy.get('h1').should('contain', 'Choose a Browser')
})

it('includes x-framework and x-dev-server in request to Cypress manifest, even when launched in e2e mode', () => {
cy.withCtx((ctx, o) => {
o.sinon.spy(ctx.util.fetch)
describe('request for Cypress manifest', () => {
beforeEach(() => {
cy.withCtx((ctx, o) => {
o.sinon.spy(ctx.util.fetch)
})

cy.scaffoldProject('todos')
cy.openProject('todos', ['--e2e'])
})

cy.scaffoldProject('todos')
cy.openProject('todos', ['--e2e'])
cy.visitLaunchpad()
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',
},
it('includes x-framework and x-dev-server, even when launched in e2e mode', () => {
cy.visitLaunchpad()
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',
},
})
})
})

describe('logged-in state', () => {
it(`sends 'false' when not logged in`, () => {
cy.visitLaunchpad()
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-logged-in': 'false',
},
})
})
})

it(`sends 'true' when logged in`, () => {
cy.loginUser()
cy.visitLaunchpad()
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-logged-in': 'true',
},
})
})
})
})
})
Expand Down

5 comments on commit 36278fc

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 36278fc Jul 19, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/linux-x64/develop-36278fca013e24c17f8060dba4c0eaed5c2d396f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 36278fc Jul 19, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/linux-arm64/develop-36278fca013e24c17f8060dba4c0eaed5c2d396f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 36278fc Jul 19, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/darwin-arm64/develop-36278fca013e24c17f8060dba4c0eaed5c2d396f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 36278fc Jul 19, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/darwin-x64/develop-36278fca013e24c17f8060dba4c0eaed5c2d396f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 36278fc Jul 19, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/win32-x64/develop-36278fca013e24c17f8060dba4c0eaed5c2d396f/cypress.tgz

Please sign in to comment.