Skip to content

Commit dcb4a61

Browse files
authored
fix: migrate multiples projects when in global mode (#21458)
* fix: migrate multiples projects when in global mode * Add test * Update test
1 parent 3a3aa10 commit dcb4a61

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

packages/data-context/src/actions/MigrationActions.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,11 @@ export class MigrationActions {
260260
throw error
261261
})
262262

263-
// @ts-ignore configFile needs to be updated with the new one, so it finds the correct one
264-
// with the new file, instead of the deleted one which is not supported anymore
265-
this.ctx.modeOptions.configFile = this.ctx.migration.configFileNameAfterMigration
263+
if (this.ctx.modeOptions.configFile) {
264+
// @ts-ignore configFile needs to be updated with the new one, so it finds the correct one
265+
// with the new file, instead of the deleted one which is not supported anymore
266+
this.ctx.modeOptions.configFile = this.ctx.migration.configFileNameAfterMigration
267+
}
266268
}
267269

268270
async setLegacyConfigForMigration (config: LegacyCypressConfigJson) {

packages/launchpad/cypress/e2e/migration.cy.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,51 @@ function renameSupport (lang: 'js' | 'ts' | 'coffee' = 'js') {
7878
}, { lang })
7979
}
8080

81+
describe('global mode', () => {
82+
it('migrates 2 projects in global mode', () => {
83+
cy.openGlobalMode()
84+
cy.addProject('migration-e2e-export-default')
85+
cy.addProject('migration-e2e-custom-integration-with-projectId')
86+
cy.visitLaunchpad()
87+
88+
cy.withCtx((ctx, o) => {
89+
o.sinon.stub(ctx.actions.migration, 'locallyInstalledCypressVersion').returns('10.0.0')
90+
})
91+
92+
cy.contains('migration-e2e-export-default').click()
93+
// rename integration->e2e
94+
cy.get(renameAutoStep).should('exist')
95+
cy.get(renameManualStep).should('not.exist')
96+
97+
// cypress/support/index.ts -> cypress/support/e2e.ts
98+
cy.get(renameSupportStep).should('exist')
99+
// no component specs
100+
cy.get(setupComponentStep).should('not.exist')
101+
102+
cy.get(configFileStep).should('exist')
103+
104+
runAutoRename()
105+
renameSupport('ts')
106+
migrateAndVerifyConfig('cypress.config.ts')
107+
checkOutcome()
108+
109+
cy.contains('Projects').click()
110+
cy.contains('migration-e2e-custom-integration-with-projectId').click()
111+
// default testFiles but custom integration - can rename automatically
112+
cy.get(renameAutoStep).should('not.exist')
113+
// no CT
114+
cy.get(renameManualStep).should('not.exist')
115+
// supportFile is false - cannot migrate
116+
cy.get(renameSupportStep).should('exist')
117+
cy.get(setupComponentStep).should('not.exist')
118+
cy.get(configFileStep).should('exist')
119+
120+
renameSupport()
121+
migrateAndVerifyConfig()
122+
checkOutcome()
123+
})
124+
})
125+
81126
describe('Opening unmigrated project', () => {
82127
it('legacy project with --e2e', () => {
83128
cy.scaffoldProject('migration')

0 commit comments

Comments
 (0)