diff --git a/src/vs/workbench/parts/experiments/electron-browser/experimentalPrompt.ts b/src/vs/workbench/parts/experiments/electron-browser/experimentalPrompt.ts index cee00f6459079292f05c84ce76cc350466052faa..929ad930b63aa9ca2cd28dc18e6b3f326b9976f5 100644 --- a/src/vs/workbench/parts/experiments/electron-browser/experimentalPrompt.ts +++ b/src/vs/workbench/parts/experiments/electron-browser/experimentalPrompt.ts @@ -64,9 +64,7 @@ export class ExperimentalPrompts extends Disposable implements IWorkbenchContrib logTelemetry(command.text); if (command.externalLink) { window.open(command.externalLink); - return; - } - if (command.curatedExtensionsKey && Array.isArray(command.curatedExtensionsList)) { + } else if (command.curatedExtensionsKey && Array.isArray(command.curatedExtensionsList)) { this.viewletService.openViewlet('workbench.view.extensions', true) .then(viewlet => viewlet as IExtensionsViewlet) .then(viewlet => { @@ -74,7 +72,6 @@ export class ExperimentalPrompts extends Disposable implements IWorkbenchContrib viewlet.search('curated:' + command.curatedExtensionsKey); } }); - return; } this.experimentService.markAsCompleted(experiment.id); @@ -83,7 +80,10 @@ export class ExperimentalPrompts extends Disposable implements IWorkbenchContrib }; }); - this.notificationService.prompt(Severity.Info, actionProperties.promptText, choices, logTelemetry); + this.notificationService.prompt(Severity.Info, actionProperties.promptText, choices, () => { + logTelemetry(); + this.experimentService.markAsCompleted(experiment.id); + }); } dispose() { diff --git a/src/vs/workbench/parts/experiments/test/electron-browser/experimentalPrompts.test.ts b/src/vs/workbench/parts/experiments/test/electron-browser/experimentalPrompts.test.ts index 3edba678b818ff6cb2037877390d97e093a81a87..7cf755ae92d934eac640d4c4077c0f7c43698924 100644 --- a/src/vs/workbench/parts/experiments/test/electron-browser/experimentalPrompts.test.ts +++ b/src/vs/workbench/parts/experiments/test/electron-browser/experimentalPrompts.test.ts @@ -42,7 +42,7 @@ suite('Experimental Prompts', () => { commands: [ { text: 'Yes', - dontShowAgain: true + externalLink: 'https://code.visualstudio.com' }, { text: 'No' @@ -88,7 +88,7 @@ suite('Experimental Prompts', () => { }); - test('Show experimental prompt if experiment should be run. Choosing an option should mark experiment as complete', () => { + test('Show experimental prompt if experiment should be run. Choosing option with link should mark experiment as complete', () => { storageData = { enabled: true, @@ -111,4 +111,52 @@ suite('Experimental Prompts', () => { }); }); + + test('Show experimental prompt if experiment should be run. Choosing negative option should mark experiment as complete', () => { + + storageData = { + enabled: true, + state: ExperimentState.Run + }; + + instantiationService.stub(INotificationService, { + prompt: (a: Severity, b: string, c: IPromptChoice[], d) => { + assert.equal(b, promptText); + assert.equal(c.length, 2); + c[1].run(); + } + }); + + experimentalPrompt = instantiationService.createInstance(ExperimentalPrompts); + onExperimentEnabledEvent.fire(experiment); + + return TPromise.as(null).then(result => { + assert.equal(storageData['state'], ExperimentState.Complete); + }); + + }); + + test('Show experimental prompt if experiment should be run. Cancelling should mark experiment as complete', () => { + + storageData = { + enabled: true, + state: ExperimentState.Run + }; + + instantiationService.stub(INotificationService, { + prompt: (a: Severity, b: string, c: IPromptChoice[], d) => { + assert.equal(b, promptText); + assert.equal(c.length, 2); + d(); + } + }); + + experimentalPrompt = instantiationService.createInstance(ExperimentalPrompts); + onExperimentEnabledEvent.fire(experiment); + + return TPromise.as(null).then(result => { + assert.equal(storageData['state'], ExperimentState.Complete); + }); + + }); }); \ No newline at end of file