From dcb4a61b4e522c676e8078732634972fe64afe5f Mon Sep 17 00:00:00 2001 From: Alejandro Estrada Date: Thu, 12 May 2022 21:48:12 -0500 Subject: [PATCH] fix: migrate multiples projects when in global mode (#21458) * fix: migrate multiples projects when in global mode * Add test * Update test --- .../src/actions/MigrationActions.ts | 8 ++-- .../launchpad/cypress/e2e/migration.cy.ts | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/packages/data-context/src/actions/MigrationActions.ts b/packages/data-context/src/actions/MigrationActions.ts index 486aee8281f5..0cb1096a3565 100644 --- a/packages/data-context/src/actions/MigrationActions.ts +++ b/packages/data-context/src/actions/MigrationActions.ts @@ -260,9 +260,11 @@ export class MigrationActions { throw error }) - // @ts-ignore configFile needs to be updated with the new one, so it finds the correct one - // with the new file, instead of the deleted one which is not supported anymore - this.ctx.modeOptions.configFile = this.ctx.migration.configFileNameAfterMigration + if (this.ctx.modeOptions.configFile) { + // @ts-ignore configFile needs to be updated with the new one, so it finds the correct one + // with the new file, instead of the deleted one which is not supported anymore + this.ctx.modeOptions.configFile = this.ctx.migration.configFileNameAfterMigration + } } async setLegacyConfigForMigration (config: LegacyCypressConfigJson) { diff --git a/packages/launchpad/cypress/e2e/migration.cy.ts b/packages/launchpad/cypress/e2e/migration.cy.ts index b275778891d5..e1342fae16c6 100644 --- a/packages/launchpad/cypress/e2e/migration.cy.ts +++ b/packages/launchpad/cypress/e2e/migration.cy.ts @@ -78,6 +78,51 @@ function renameSupport (lang: 'js' | 'ts' | 'coffee' = 'js') { }, { lang }) } +describe('global mode', () => { + it('migrates 2 projects in global mode', () => { + cy.openGlobalMode() + cy.addProject('migration-e2e-export-default') + cy.addProject('migration-e2e-custom-integration-with-projectId') + cy.visitLaunchpad() + + cy.withCtx((ctx, o) => { + o.sinon.stub(ctx.actions.migration, 'locallyInstalledCypressVersion').returns('10.0.0') + }) + + cy.contains('migration-e2e-export-default').click() + // rename integration->e2e + cy.get(renameAutoStep).should('exist') + cy.get(renameManualStep).should('not.exist') + + // cypress/support/index.ts -> cypress/support/e2e.ts + cy.get(renameSupportStep).should('exist') + // no component specs + cy.get(setupComponentStep).should('not.exist') + + cy.get(configFileStep).should('exist') + + runAutoRename() + renameSupport('ts') + migrateAndVerifyConfig('cypress.config.ts') + checkOutcome() + + cy.contains('Projects').click() + cy.contains('migration-e2e-custom-integration-with-projectId').click() + // default testFiles but custom integration - can rename automatically + cy.get(renameAutoStep).should('not.exist') + // no CT + cy.get(renameManualStep).should('not.exist') + // supportFile is false - cannot migrate + cy.get(renameSupportStep).should('exist') + cy.get(setupComponentStep).should('not.exist') + cy.get(configFileStep).should('exist') + + renameSupport() + migrateAndVerifyConfig() + checkOutcome() + }) +}) + describe('Opening unmigrated project', () => { it('legacy project with --e2e', () => { cy.scaffoldProject('migration')