diff --git a/src/extension.ts b/src/extension.ts index 7148403e3..bb1cd8d39 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -234,9 +234,6 @@ export class Extension { const configFiles = await this._vscode.workspace.findFiles('**/*playwright*.config.{ts,js,mjs}', '**/node_modules/**'); - // Reuse already created run profiles in order to retain their 'selected' status. - const usedProfiles = new Set(); - const configErrors = new MultiMap(); for (const configFileUri of configFiles) { const configFilePath = configFileUri.fsPath; @@ -281,19 +278,11 @@ export class Extension { } for (const project of model.projects.values()) { - await this._createRunProfile(project, usedProfiles); + await this._createRunProfile(project); this._workspaceObserver.addWatchFolder(project.testDir); } } - // Clean up unused run profiles. - for (const [key, profile] of this._runProfiles) { - if (!usedProfiles.has(profile)) { - this._runProfiles.delete(key); - profile.dispose(); - } - } - this._settingsView.updateActions(); this._testTree.finishedLoading(); @@ -337,7 +326,7 @@ export class Extension { })) as NodeJS.ProcessEnv; } - private async _createRunProfile(project: TestProject, usedProfiles: Set) { + private async _createRunProfile(project: TestProject) { const configFile = project.model.config.configFile; const configName = path.basename(configFile); const folderName = path.basename(path.dirname(configFile)); @@ -346,16 +335,14 @@ export class Extension { let runProfile = this._runProfiles.get(keyPrefix + ':run'); const projectTag = this._testTree.projectTag(project); if (!runProfile) { - runProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Run, this._scheduleTestRunRequest.bind(this, configFile, project.name, false), true, projectTag); + runProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Run, this._scheduleTestRunRequest.bind(this, configFile, project.name, false), false, projectTag); this._runProfiles.set(keyPrefix + ':run', runProfile); } let debugProfile = this._runProfiles.get(keyPrefix + ':debug'); if (!debugProfile) { - debugProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Debug, this._scheduleTestRunRequest.bind(this, configFile, project.name, true), true, projectTag); + debugProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Debug, this._scheduleTestRunRequest.bind(this, configFile, project.name, true), false, projectTag); this._runProfiles.set(keyPrefix + ':debug', debugProfile); } - usedProfiles.add(runProfile); - usedProfiles.add(debugProfile); } private _scheduleTestRunRequest(configFile: string, projectName: string, isDebug: boolean, request: vscodeTypes.TestRunRequest) { diff --git a/tests/profile-discovery.spec.ts b/tests/profile-discovery.spec.ts index fc66a5748..f6201de22 100644 --- a/tests/profile-discovery.spec.ts +++ b/tests/profile-discovery.spec.ts @@ -75,28 +75,3 @@ test('should create run & debug profile per project', async ({ activate }, testI > playwright list-files -c playwright.config.js `); }); - -test('retain run profile instances of reload', async ({ activate }, testInfo) => { - const { testController, workspaceFolder } = await activate({ - 'playwright.config.js': `module.exports = { - projects: [{ name: 'projectA' }, { name: 'projectB' }] - }` - }, { rootDir: testInfo.outputPath('workspace') }); - - const runProfiles = new Set(testController.runProfiles); - - await workspaceFolder.changeFile('playwright.config.js', `module.exports = { - projects: [{ name: 'projectA' }, { name: 'projectC' }, { name: 'projectD' }] - }`); - - while (testController.runProfiles.length !== 6) - await new Promise(f => setTimeout(f, 100)); - - let retained = 0; - for (const profile of testController.runProfiles) { - if (runProfiles.has(profile)) - ++retained; - } - - expect(retained).toBe(2); // Run & Debug projects from project A. -});