Skip to content

Commit d498e85

Browse files
author
Kartik Raj
authored
Do not opt users out of the insiders program if they have a stable version installed (#14091)
* Remove code that opts users out of the insiders program * News entry * Code reviews
1 parent 6abde6b commit d498e85

File tree

3 files changed

+27
-134
lines changed

3 files changed

+27
-134
lines changed

news/1 Enhancements/14090.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not opt users out of the insiders program if they have a stable version installed.

src/client/common/insidersBuild/insidersExtensionService.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class InsidersExtensionService implements IExtensionSingleActivationServi
6161
const channel = this.extensionChannelService.getChannel();
6262
const isDefault = this.extensionChannelService.isChannelUsingDefaultConfiguration;
6363

64-
const alreadyHandled = await this.handleEdgeCases(channel, isDefault);
64+
const alreadyHandled = await this.handleEdgeCases(isDefault);
6565
if (!alreadyHandled) {
6666
this.handleChannel(channel).ignoreErrors();
6767
}
@@ -84,14 +84,12 @@ export class InsidersExtensionService implements IExtensionSingleActivationServi
8484
* Choose what to do in miscellaneous situations
8585
* @returns `true` if install channel is handled in these miscellaneous cases, `false` if install channel needs further handling
8686
*/
87-
public async handleEdgeCases(installChannel: ExtensionChannels, isDefault: boolean): Promise<boolean> {
87+
public async handleEdgeCases(isDefault: boolean): Promise<boolean> {
8888
// When running UI Tests we might want to disable these prompts.
8989
if (process.env.UITEST_DISABLE_INSIDERS) {
9090
return true;
9191
} else if (await this.promptToInstallInsidersIfApplicable(isDefault)) {
9292
return true;
93-
} else if (await this.setInsidersChannelToOffIfApplicable(installChannel)) {
94-
return true;
9593
} else {
9694
return false;
9795
}
@@ -115,21 +113,4 @@ export class InsidersExtensionService implements IExtensionSingleActivationServi
115113
await this.insidersPrompt.promptToInstallInsiders();
116114
return true;
117115
}
118-
119-
/**
120-
* When install channel is not in sync with what is installed, resolve discrepency by setting channel to "off"
121-
* @returns `true` if channel is set to off, `false` otherwise
122-
*/
123-
private async setInsidersChannelToOffIfApplicable(installChannel: ExtensionChannels): Promise<boolean> {
124-
if (installChannel === 'off') {
125-
return false;
126-
}
127-
if (this.appEnvironment.extensionChannel !== 'stable') {
128-
return false;
129-
}
130-
131-
// Install channel is set to "weekly" or "daily" but stable version of extension is installed. Switch channel to "off" to use the installed version
132-
await this.extensionChannelService.updateChannel('off');
133-
return true;
134-
}
135116
}

src/test/common/insidersBuild/insidersExtensionService.unit.test.ts

Lines changed: 24 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ suite('Insiders Extension Service - Activation', () => {
150150
verify(extensionChannelService.isChannelUsingDefaultConfiguration).once();
151151
assert.ok(registerCommandsAndHandlers.calledOnce);
152152
assert.ok(handleEdgeCases.calledOnce);
153-
assert.ok(handleEdgeCases.calledWith('daily', false));
153+
assert.ok(handleEdgeCases.calledWith(false));
154154
assert.ok(handleChannel.notCalled);
155155
});
156156

@@ -176,7 +176,7 @@ suite('Insiders Extension Service - Activation', () => {
176176
verify(extensionChannelService.isChannelUsingDefaultConfiguration).once();
177177
assert.ok(registerCommandsAndHandlers.calledOnce);
178178
assert.ok(handleEdgeCases.calledOnce);
179-
assert.ok(handleEdgeCases.calledWith('daily', false));
179+
assert.ok(handleEdgeCases.calledWith(false));
180180
assert.ok(handleChannel.calledOnce);
181181
});
182182

@@ -210,7 +210,7 @@ suite('Insiders Extension Service - Activation', () => {
210210
assert.ok(registerCommandsAndHandlers.calledOnce);
211211
assert.ok(handleEdgeCases.calledOnce);
212212
assert.ok(handleChannel.calledOnce);
213-
assert.ok(handleEdgeCases.calledWith('daily', false));
213+
assert.ok(handleEdgeCases.calledWith(false));
214214
});
215215
});
216216

@@ -252,6 +252,10 @@ suite('Insiders Extension Service - Function handleEdgeCases()', () => {
252252
.verifiable(TypeMoq.Times.atLeast(0));
253253
}
254254

255+
setup(() => {
256+
setupCommon();
257+
});
258+
255259
function verifyAll() {
256260
// the most important ones:
257261
insidersPrompt.verifyAll();
@@ -265,23 +269,16 @@ suite('Insiders Extension Service - Function handleEdgeCases()', () => {
265269

266270
type TestInfo = {
267271
vscodeChannel?: Channel;
268-
extensionChannel?: Channel;
269-
installChannel: ExtensionChannels;
272+
installChannel?: ExtensionChannels;
270273
isChannelUsingDefaultConfiguration?: boolean;
271274
hasUserBeenNotified?: boolean;
272275
};
273276

274-
function setState(info: TestInfo, checkPromptEnroll: boolean, checkDisable: boolean) {
277+
function setState(info: TestInfo, checkPromptEnroll: boolean) {
275278
if (info.vscodeChannel) {
276279
appEnvironment.setup((e) => e.channel).returns(() => info.vscodeChannel!);
277280
}
278-
if (info.extensionChannel) {
279-
appEnvironment.setup((e) => e.extensionChannel).returns(() => info.extensionChannel!);
280-
}
281281

282-
if (checkDisable) {
283-
extensionChannelService.setup((ec) => ec.updateChannel('off')).returns(() => Promise.resolve());
284-
}
285282
if (info.hasUserBeenNotified !== undefined) {
286283
when(hasUserBeenNotifiedState.value).thenReturn(info.hasUserBeenNotified!);
287284
}
@@ -290,125 +287,42 @@ suite('Insiders Extension Service - Function handleEdgeCases()', () => {
290287
}
291288
}
292289

293-
suite('Case II - Verify Insiders Install Prompt is displayed when conditions are met', async () => {
294-
const testsForHandleEdgeCaseII: TestInfo[] = [
290+
test(`Insiders Install Prompt is displayed when vscode channel = 'insiders', user has not been notified to install insiders, isChannelUsingDefaultConfiguration = true`, async () => {
291+
setState(
295292
{
296-
installChannel: 'daily',
297293
// prompt to enroll
298294
vscodeChannel: 'insiders',
299295
hasUserBeenNotified: false,
300296
isChannelUsingDefaultConfiguration: true
301297
},
302-
{
303-
installChannel: 'off',
304-
// prompt to enroll
305-
vscodeChannel: 'insiders',
306-
hasUserBeenNotified: false,
307-
isChannelUsingDefaultConfiguration: true
308-
}
309-
];
310-
311-
setup(() => {
312-
setupCommon();
313-
});
314-
315-
testsForHandleEdgeCaseII.forEach((testParams) => {
316-
const testName = `Insiders Install Prompt is displayed when vscode channel = '${
317-
testParams.vscodeChannel
318-
}', extension channel = '${testParams.extensionChannel}', install channel = '${
319-
testParams.installChannel
320-
}', ${
321-
!testParams.hasUserBeenNotified
322-
? 'user has not been notified to install insiders'
323-
: 'user has already been notified to install insiders'
324-
}, isChannelUsingDefaultConfiguration = ${testParams.isChannelUsingDefaultConfiguration}`;
325-
test(testName, async () => {
326-
setState(testParams, true, false);
327-
328-
await insidersExtensionService.handleEdgeCases(
329-
testParams.installChannel,
330-
testParams.isChannelUsingDefaultConfiguration!
331-
);
332-
333-
verifyAll();
334-
verify(hasUserBeenNotifiedState.value).once();
335-
});
336-
});
337-
});
338-
339-
suite('Case III - Verify Insiders channel is set to off when conditions are met', async () => {
340-
const testsForHandleEdgeCaseIII: TestInfo[] = [
341-
{
342-
installChannel: 'daily',
343-
// skip enroll
344-
vscodeChannel: 'stable',
345-
// disable
346-
// with installChannel from above
347-
extensionChannel: 'stable'
348-
},
349-
{
350-
installChannel: 'weekly',
351-
// skip enroll
352-
vscodeChannel: 'stable',
353-
// disable
354-
// with installChannel from above
355-
extensionChannel: 'stable'
356-
}
357-
];
358-
359-
setup(() => {
360-
setupCommon();
361-
});
298+
true
299+
);
362300

363-
testsForHandleEdgeCaseIII.forEach((testParams) => {
364-
const testName = `Insiders channel is set to off when vscode channel = '${
365-
testParams.vscodeChannel
366-
}', extension channel = '${testParams.extensionChannel}', install channel = '${
367-
testParams.installChannel
368-
}', ${
369-
!testParams.hasUserBeenNotified
370-
? 'user has not been notified to install insiders'
371-
: 'user has already been notified to install insiders'
372-
}, isChannelUsingDefaultConfiguration = ${testParams.isChannelUsingDefaultConfiguration}`;
373-
test(testName, async () => {
374-
setState(testParams, false, true);
301+
await insidersExtensionService.handleEdgeCases(true);
375302

376-
await insidersExtensionService.handleEdgeCases(
377-
testParams.installChannel,
378-
false // isDefault
379-
);
380-
381-
verifyAll();
382-
verify(hasUserBeenNotifiedState.value).never();
383-
});
384-
});
303+
verifyAll();
304+
verify(hasUserBeenNotifiedState.value).once();
385305
});
386306

387-
suite('Case IV - Verify no operation is performed if none of the case conditions are met', async () => {
388-
const testsForHandleEdgeCaseIV: TestInfo[] = [
307+
suite('Verify no operation is performed if none of the case conditions are met', async () => {
308+
const testsForHandleEdgeCases: TestInfo[] = [
389309
{
390310
installChannel: 'daily',
391311
// skip enroll
392312
vscodeChannel: 'insiders',
393-
hasUserBeenNotified: true,
394-
// skip disable
395-
extensionChannel: 'insiders'
313+
hasUserBeenNotified: true
396314
},
397315
{
398316
installChannel: 'daily',
399317
// skip enroll
400318
vscodeChannel: 'insiders',
401319
hasUserBeenNotified: false,
402-
isChannelUsingDefaultConfiguration: false,
403-
// skip disable
404-
extensionChannel: 'insiders'
320+
isChannelUsingDefaultConfiguration: false
405321
},
406322
{
407323
installChannel: 'daily',
408324
// skip enroll
409-
vscodeChannel: 'stable',
410-
// skip disable
411-
extensionChannel: 'insiders'
325+
vscodeChannel: 'stable'
412326
},
413327
{
414328
installChannel: 'off',
@@ -436,21 +350,18 @@ suite('Insiders Extension Service - Function handleEdgeCases()', () => {
436350
setupCommon();
437351
});
438352

439-
testsForHandleEdgeCaseIV.forEach((testParams) => {
353+
testsForHandleEdgeCases.forEach((testParams) => {
440354
const testName = `No operation is performed when vscode channel = '${
441355
testParams.vscodeChannel
442-
}', extension channel = '${testParams.extensionChannel}', install channel = '${
443-
testParams.installChannel
444-
}', ${
356+
}', install channel = '${testParams.installChannel}', ${
445357
!testParams.hasUserBeenNotified
446358
? 'user has not been notified to install insiders'
447359
: 'user has already been notified to install insiders'
448360
}, isChannelUsingDefaultConfiguration = ${testParams.isChannelUsingDefaultConfiguration}`;
449361
test(testName, async () => {
450-
setState(testParams, false, false);
362+
setState(testParams, false);
451363

452364
await insidersExtensionService.handleEdgeCases(
453-
testParams.installChannel,
454365
testParams.isChannelUsingDefaultConfiguration || testParams.installChannel === 'off'
455366
);
456367

0 commit comments

Comments
 (0)