Skip to content

Commit

Permalink
fix: initialization lifecycle after project setup (#20906)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel authored Apr 5, 2022
1 parent ae9a071 commit ba93023
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/data-context/src/actions/WizardActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export class WizardActions {
this.ctx.update((d) => {
d.scaffoldedFiles = null
})

this.ctx.lifecycleManager.loadTestingType()
}

/// reset wizard status, useful for when changing to a new project
Expand Down
6 changes: 6 additions & 0 deletions packages/data-context/src/data/ProjectLifecycleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ export class ProjectLifecycleManager {
}
}

loadTestingType () {
assert(this._configManager, 'Cannot load a testing type without a config manager')

this._configManager.loadTestingType()
}

scaffoldFilesIfNecessary () {
if (this._currentTestingType && this._projectMetaState.hasValidConfigFile && !this.isTestingTypeConfigured(this._currentTestingType) && !this.ctx.isRunMode) {
this.ctx.actions.wizard.scaffoldTestingType().catch(this.onLoadError)
Expand Down
38 changes: 28 additions & 10 deletions packages/launchpad/cypress/e2e/project-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ describe('Launchpad: Setup Project', () => {
cy.contains('[data-cy-testingtype="component"]', ctIsConfigured ? 'Configured' : 'Not Configured')
}

const verifyChooseABrowserPage = () => {
cy.contains('Choose a Browser', { timeout: 10000 })

cy.findByRole('radio', { name: 'Chrome v1' })
cy.findByRole('radio', { name: 'Firefox v5' })
cy.findByRole('radio', { name: 'Electron v12' })
cy.findByRole('radio', { name: 'Edge v8' })
}

beforeEach(() => {
cy.findBrowsers({
filter: (browser) => {
return Cypress._.includes(['chrome', 'firefox', 'electron', 'edge'], browser.name) && browser.channel === 'stable'
},
})
})

it('no initial setup displays welcome page', () => {
scaffoldAndOpenProject('pristine')
cy.visitLaunchpad()
Expand Down Expand Up @@ -166,14 +183,14 @@ describe('Launchpad: Setup Project', () => {

cy.get('[data-cy-testingtype="e2e"]').click()

cy.contains(/(Initializing Config|Choose a Browser)/, { timeout: 10000 })
verifyChooseABrowserPage()
})

it('opens to the browser pages when opened via cli with --e2e flag', () => {
scaffoldAndOpenProject('pristine-with-e2e-testing', ['--e2e'])
cy.visitLaunchpad()

cy.get('h1').should('contain', 'Choose a Browser')
verifyChooseABrowserPage()
})
})

Expand Down Expand Up @@ -321,7 +338,7 @@ describe('Launchpad: Setup Project', () => {
.should('not.have.disabled')
.click()

cy.contains(/(Initializing Config|Choose a Browser)/, { timeout: 10000 })
verifyChooseABrowserPage()
})

it('can setup e2e testing for a project selecting TS', () => {
Expand Down Expand Up @@ -596,8 +613,7 @@ describe('Launchpad: Setup Project', () => {
cy.get('[data-cy="Choose a Browser"]').click()
})

cy.contains('Choose a Browser')
cy.contains('Choose your preferred browser for E2E testing.')
verifyChooseABrowserPage()
})

it('can reconfigure config from the testing type card selecting E2E', () => {
Expand Down Expand Up @@ -629,7 +645,7 @@ describe('Launchpad: Setup Project', () => {
cy.get('[data-cy="Choose a Browser"]').click()
})

cy.contains('Choose a Browser')
verifyChooseABrowserPage()
})

it('can reconfigure config from the testing type card selecting Component', () => {
Expand Down Expand Up @@ -662,14 +678,14 @@ describe('Launchpad: Setup Project', () => {

cy.get('[data-cy-testingtype="component"]').click()

cy.contains(/(Initializing Config|Choose a Browser)/, { timeout: 10000 })
verifyChooseABrowserPage()
})

it('opens to the browser pages when opened via cli with --component flag', () => {
scaffoldAndOpenProject('pristine-with-ct-testing', ['--component'])
cy.visitLaunchpad()

cy.get('h1').should('contain', 'Choose a Browser')
verifyChooseABrowserPage()
})
})

Expand Down Expand Up @@ -877,7 +893,8 @@ describe('Launchpad: Setup Project', () => {
})

cy.findByRole('button', { name: 'Continue' }).click()
cy.contains(/(Initializing Config|Choose a Browser)/, { timeout: 10000 })

verifyChooseABrowserPage()
})

it('setup component testing with typescript files', () => {
Expand Down Expand Up @@ -912,7 +929,8 @@ describe('Launchpad: Setup Project', () => {
verifyFiles(['cypress.config.ts', 'cypress/support/component-index.html', 'cypress/support/component.ts', 'cypress/support/commands.ts', 'cypress/fixtures/example.json'])

cy.findByRole('button', { name: 'Continue' }).click()
cy.contains(/(Initializing Config|Choose a Browser)/, { timeout: 10000 })

verifyChooseABrowserPage()
})
})
})
Expand Down

3 comments on commit ba93023

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ba93023 Apr 5, 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.0.0/linux-x64/10.0-release-ba93023f2b95280adbde979a3eb7dc1936a8dbdb/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ba93023 Apr 5, 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.0.0/darwin-x64/10.0-release-ba93023f2b95280adbde979a3eb7dc1936a8dbdb/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ba93023 Apr 5, 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.0.0/win32-x64/10.0-release-ba93023f2b95280adbde979a3eb7dc1936a8dbdb/cypress.tgz

Please sign in to comment.