From c4ef73df238f737319caacdf1faceea38cb66f26 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 19 Aug 2024 13:45:33 +0200 Subject: [PATCH 1/9] feat: show survey VSCODE-562 --- src/mdbExtensionController.ts | 36 ++++++++++++++++++++++++++++++++ src/storage/storageController.ts | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 791d85287..e2d062993 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -150,6 +150,7 @@ export default class MDBExtensionController implements vscode.Disposable { this.registerCommands(); this.showOverviewPageIfRecentlyInstalled(); + void this.showSurveyForEstablishedUsers(); } registerCommands = (): void => { @@ -815,6 +816,41 @@ export default class MDBExtensionController implements vscode.Disposable { } } + async showSurveyForEstablishedUsers(): Promise { + const surveyId = '9viN9wcbsC3zvHyg7'; + + const hasBeenShownSurveyAlready = + this._storageController.get(StorageVariables.GLOBAL_SURVEY_SHOWN) === + surveyId; + + // Show the overview page when it hasn't been show to the + // user yet, and they have saved connections + // -> they haven't just started using this extension + if (!hasBeenShownSurveyAlready) { + if (this._connectionStorage.hasSavedConnections()) { + const action = 'Share your thoughts'; + const text = 'How can we make the MongoDB extension better for you?'; + const link = 'https://forms.gle/9viN9wcbsC3zvHyg7'; + const result = await vscode.window.showInformationMessage( + text, + {}, + { + title: action, + } + ); + if (result && result.title === action) { + void vscode.env.openExternal(vscode.Uri.parse(link)); + } + + // whether action was taken or the prompt dismissed, we won't show this again + void this._storageController.update( + StorageVariables.GLOBAL_SURVEY_SHOWN, + surveyId + ); + } + } + } + async dispose(): Promise { await this.deactivate(); } diff --git a/src/storage/storageController.ts b/src/storage/storageController.ts index 3ae1a71ec..0148208b9 100644 --- a/src/storage/storageController.ts +++ b/src/storage/storageController.ts @@ -6,6 +6,7 @@ import type { StoreConnectionInfo } from './connectionStorage'; export enum StorageVariables { // Only exists on globalState. GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW = 'GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW', + GLOBAL_SURVEY_SHOWN = 'GLOBAL_SURVEY_SHOWN', GLOBAL_SAVED_CONNECTIONS = 'GLOBAL_SAVED_CONNECTIONS', // Analytics user identify. GLOBAL_USER_ID = 'GLOBAL_USER_ID', @@ -50,6 +51,7 @@ interface StorageVariableContents { [StorageVariables.GLOBAL_USER_ID]: string; [StorageVariables.GLOBAL_ANONYMOUS_ID]: string; [StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW]: boolean; + [StorageVariables.GLOBAL_SURVEY_SHOWN]: string; [StorageVariables.GLOBAL_SAVED_CONNECTIONS]: ConnectionsFromStorage; [StorageVariables.WORKSPACE_SAVED_CONNECTIONS]: ConnectionsFromStorage; } From 2ae75c31079092c8b802300d29eb8fbd03832f4e Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 19 Aug 2024 14:19:51 +0200 Subject: [PATCH 2/9] add test --- src/test/suite/mdbExtensionController.test.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 9fc872a19..7f9b28c6b 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -1717,5 +1717,80 @@ suite('MDBExtensionController Test Suite', function () { }); }); }); + + suite('survey prompt', function () { + suite( + "when a user hasn't been shown the survey prompt yet, and they have connections saved", + () => { + for (const reaction of [ + { description: 'clicked the button', value: 'Share your thoughts' }, + { description: 'dismissed', value: undefined }, + ]) { + let showInformationMessageStub: SinonStub; + let fakeUpdate: SinonSpy; + let openExternalStub: SinonStub; + beforeEach(() => { + showInformationMessageStub = sandbox.stub( + vscode.window, + 'showInformationMessage' + ); + showInformationMessageStub.resolves(reaction.value); + openExternalStub = sandbox.stub(vscode.env, 'openExternal'); + openExternalStub.resolves(undefined); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'get', + sandbox.fake.returns(undefined) + ); + sandbox.replace( + mdbTestExtension.testExtensionController._connectionStorage, + 'hasSavedConnections', + sandbox.fake.returns(true) + ); + fakeUpdate = sandbox.fake.resolves(undefined); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'update', + fakeUpdate + ); + void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); + }); + + test('they are shown the survey prompt', () => { + assert(showInformationMessageStub.called); + assert.strictEqual( + showInformationMessageStub.firstCall.args[0], + 'How can we make the MongoDB extension better for you?' + ); + }); + + test(`user ${reaction.description}`, () => { + if (reaction.value === undefined) { + assert(openExternalStub.notCalled); + } + if (reaction.value) { + assert(openExternalStub.called); + assert.strictEqual( + openExternalStub.firstCall.args[0], + 'https://forms.gle/9viN9wcbsC3zvHyg7' + ); + } + }); + + test("it sets that they've been shown the survey", () => { + assert(fakeUpdate.called); + assert.strictEqual( + fakeUpdate.firstCall.args[0], + StorageVariables.GLOBAL_SURVEY_SHOWN + ); + assert.strictEqual( + fakeUpdate.firstCall.args[1], + '9viN9wcbsC3zvHyg7' + ); + }); + } + } + ); + }); }); }); From 75fc85887df46e642d72dbcace13cfbc76d4df3e Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 19 Aug 2024 15:34:11 +0200 Subject: [PATCH 3/9] more tests --- src/test/suite/mdbExtensionController.test.ts | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 7f9b28c6b..a14a8fac1 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -1729,7 +1729,7 @@ suite('MDBExtensionController Test Suite', function () { let showInformationMessageStub: SinonStub; let fakeUpdate: SinonSpy; let openExternalStub: SinonStub; - beforeEach(() => { + before(() => { showInformationMessageStub = sandbox.stub( vscode.window, 'showInformationMessage' @@ -1791,6 +1791,70 @@ suite('MDBExtensionController Test Suite', function () { } } ); + + suite('when a user has been shown the survey prompt already', () => { + let showInformationMessageStub: SinonStub; + let fakeUpdate: SinonSpy; + before(() => { + showInformationMessageStub = sandbox.stub( + vscode.window, + 'showInformationMessage' + ); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'get', + sandbox.fake.returns('9viN9wcbsC3zvHyg7') // survey has been shown + ); + sandbox.replace( + mdbTestExtension.testExtensionController._connectionStorage, + 'hasSavedConnections', + sandbox.fake.returns(true) + ); + fakeUpdate = sandbox.fake.resolves(undefined); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'update', + fakeUpdate + ); + void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); + }); + + test('they are not shown the survey prompt', () => { + assert(showInformationMessageStub.notCalled); + }); + }); + + suite('when a has no connections saved', () => { + let showInformationMessageStub: SinonStub; + let fakeUpdate: SinonSpy; + before(() => { + showInformationMessageStub = sandbox.stub( + vscode.window, + 'showInformationMessage' + ); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'get', + sandbox.fake.returns(undefined) + ); + sandbox.replace( + mdbTestExtension.testExtensionController._connectionStorage, + 'hasSavedConnections', + sandbox.fake.returns(false) // no connections yet - this might be the first install + ); + fakeUpdate = sandbox.fake.resolves(undefined); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'update', + fakeUpdate + ); + void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); + }); + + test('they are not shown the survey prompt', () => { + assert(showInformationMessageStub.notCalled); + }); + }); }); }); }); From 0a270354a6da4644ddd59696d1e0ca7b55cd3462 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 19 Aug 2024 18:37:23 +0200 Subject: [PATCH 4/9] update tests --- src/test/suite/mdbExtensionController.test.ts | 70 ++++++++----------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index a14a8fac1..013704729 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -175,6 +175,7 @@ suite('MDBExtensionController Test Suite', function () { let fakeActiveConnectionId: SinonSpy; let showErrorMessageStub: SinonStub; let fakeCreatePlaygroundFileWithContent: SinonSpy; + let openExternalStub: SinonStub; const sandbox = sinon.createSandbox(); @@ -183,6 +184,7 @@ suite('MDBExtensionController Test Suite', function () { vscode.window, 'showInformationMessage' ); + openExternalStub = sandbox.stub(vscode.env, 'openExternal'); openTextDocumentStub = sandbox.stub(vscode.workspace, 'openTextDocument'); fakeActiveConnectionId = sandbox.fake.returns('tasty_sandwhich'); sandbox.replace( @@ -1722,20 +1724,13 @@ suite('MDBExtensionController Test Suite', function () { suite( "when a user hasn't been shown the survey prompt yet, and they have connections saved", () => { - for (const reaction of [ + [ { description: 'clicked the button', value: 'Share your thoughts' }, { description: 'dismissed', value: undefined }, - ]) { - let showInformationMessageStub: SinonStub; - let fakeUpdate: SinonSpy; - let openExternalStub: SinonStub; - before(() => { - showInformationMessageStub = sandbox.stub( - vscode.window, - 'showInformationMessage' - ); + ].forEach((reaction) => { + let connectionsUpdateStub: SinonStub; + beforeEach(() => { showInformationMessageStub.resolves(reaction.value); - openExternalStub = sandbox.stub(vscode.env, 'openExternal'); openExternalStub.resolves(undefined); sandbox.replace( mdbTestExtension.testExtensionController._storageController, @@ -1747,15 +1742,18 @@ suite('MDBExtensionController Test Suite', function () { 'hasSavedConnections', sandbox.fake.returns(true) ); - fakeUpdate = sandbox.fake.resolves(undefined); - sandbox.replace( + connectionsUpdateStub = sandbox.stub( mdbTestExtension.testExtensionController._storageController, - 'update', - fakeUpdate + 'update' ); + connectionsUpdateStub.resolves(undefined); void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); }); + afterEach(() => { + sandbox.restore(); + }); + test('they are shown the survey prompt', () => { assert(showInformationMessageStub.called); assert.strictEqual( @@ -1778,28 +1776,23 @@ suite('MDBExtensionController Test Suite', function () { }); test("it sets that they've been shown the survey", () => { - assert(fakeUpdate.called); + assert(connectionsUpdateStub.called); assert.strictEqual( - fakeUpdate.firstCall.args[0], + connectionsUpdateStub.firstCall.args[0], StorageVariables.GLOBAL_SURVEY_SHOWN ); assert.strictEqual( - fakeUpdate.firstCall.args[1], + connectionsUpdateStub.firstCall.args[1], '9viN9wcbsC3zvHyg7' ); }); - } + }); } ); suite('when a user has been shown the survey prompt already', () => { - let showInformationMessageStub: SinonStub; - let fakeUpdate: SinonSpy; - before(() => { - showInformationMessageStub = sandbox.stub( - vscode.window, - 'showInformationMessage' - ); + let connectionsUpdateStub: SinonStub; + beforeEach(() => { sandbox.replace( mdbTestExtension.testExtensionController._storageController, 'get', @@ -1810,12 +1803,12 @@ suite('MDBExtensionController Test Suite', function () { 'hasSavedConnections', sandbox.fake.returns(true) ); - fakeUpdate = sandbox.fake.resolves(undefined); - sandbox.replace( + connectionsUpdateStub = sandbox.stub( mdbTestExtension.testExtensionController._storageController, - 'update', - fakeUpdate + 'update' ); + connectionsUpdateStub.resolves(undefined); + void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); }); @@ -1825,13 +1818,8 @@ suite('MDBExtensionController Test Suite', function () { }); suite('when a has no connections saved', () => { - let showInformationMessageStub: SinonStub; - let fakeUpdate: SinonSpy; - before(() => { - showInformationMessageStub = sandbox.stub( - vscode.window, - 'showInformationMessage' - ); + let connectionsUpdateStub: SinonStub; + beforeEach(() => { sandbox.replace( mdbTestExtension.testExtensionController._storageController, 'get', @@ -1842,12 +1830,12 @@ suite('MDBExtensionController Test Suite', function () { 'hasSavedConnections', sandbox.fake.returns(false) // no connections yet - this might be the first install ); - fakeUpdate = sandbox.fake.resolves(undefined); - sandbox.replace( + connectionsUpdateStub = sandbox.stub( mdbTestExtension.testExtensionController._storageController, - 'update', - fakeUpdate + 'update' ); + connectionsUpdateStub.resolves(undefined); + void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); }); From 21262be3d99518fde4c2bbf2c1641296385ec0c9 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Tue, 20 Aug 2024 10:30:19 +0200 Subject: [PATCH 5/9] tests --- src/test/suite/mdbExtensionController.test.ts | 115 +++++++++--------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 013704729..4a7999714 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -176,6 +176,7 @@ suite('MDBExtensionController Test Suite', function () { let showErrorMessageStub: SinonStub; let fakeCreatePlaygroundFileWithContent: SinonSpy; let openExternalStub: SinonStub; + let uriParseStub: SinonStub; const sandbox = sinon.createSandbox(); @@ -185,6 +186,7 @@ suite('MDBExtensionController Test Suite', function () { 'showInformationMessage' ); openExternalStub = sandbox.stub(vscode.env, 'openExternal'); + uriParseStub = sandbox.stub(vscode.Uri, 'parse'); openTextDocumentStub = sandbox.stub(vscode.workspace, 'openTextDocument'); fakeActiveConnectionId = sandbox.fake.returns('tasty_sandwhich'); sandbox.replace( @@ -1725,66 +1727,69 @@ suite('MDBExtensionController Test Suite', function () { "when a user hasn't been shown the survey prompt yet, and they have connections saved", () => { [ - { description: 'clicked the button', value: 'Share your thoughts' }, - { description: 'dismissed', value: undefined }, + { description: 'clicked the button', value: { title: 'Share your thoughts' } }, + // { description: 'dismissed', value: undefined }, ].forEach((reaction) => { - let connectionsUpdateStub: SinonStub; - beforeEach(() => { - showInformationMessageStub.resolves(reaction.value); - openExternalStub.resolves(undefined); - sandbox.replace( - mdbTestExtension.testExtensionController._storageController, - 'get', - sandbox.fake.returns(undefined) - ); - sandbox.replace( - mdbTestExtension.testExtensionController._connectionStorage, - 'hasSavedConnections', - sandbox.fake.returns(true) - ); - connectionsUpdateStub = sandbox.stub( - mdbTestExtension.testExtensionController._storageController, - 'update' - ); - connectionsUpdateStub.resolves(undefined); - void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); - }); - - afterEach(() => { - sandbox.restore(); - }); + suite(`user ${reaction.description}`, () => { + let connectionsUpdateStub: SinonStub; + beforeEach(async () => { + showInformationMessageStub.resolves(reaction.value); + openExternalStub.resolves(undefined); + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'get', + sandbox.fake.returns(undefined) + ); + sandbox.replace( + mdbTestExtension.testExtensionController._connectionStorage, + 'hasSavedConnections', + sandbox.fake.returns(true) + ); + connectionsUpdateStub = sandbox.stub( + mdbTestExtension.testExtensionController._storageController, + 'update' + ); + connectionsUpdateStub.resolves(undefined); + await mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); + }); - test('they are shown the survey prompt', () => { - assert(showInformationMessageStub.called); - assert.strictEqual( - showInformationMessageStub.firstCall.args[0], - 'How can we make the MongoDB extension better for you?' - ); - }); + afterEach(() => { + sandbox.restore(); + }); - test(`user ${reaction.description}`, () => { - if (reaction.value === undefined) { - assert(openExternalStub.notCalled); - } - if (reaction.value) { - assert(openExternalStub.called); + test('they are shown the survey prompt', () => { + assert(showInformationMessageStub.called); assert.strictEqual( - openExternalStub.firstCall.args[0], - 'https://forms.gle/9viN9wcbsC3zvHyg7' + showInformationMessageStub.firstCall.args[0], + 'How can we make the MongoDB extension better for you?' ); - } - }); - - test("it sets that they've been shown the survey", () => { - assert(connectionsUpdateStub.called); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[0], - StorageVariables.GLOBAL_SURVEY_SHOWN - ); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[1], - '9viN9wcbsC3zvHyg7' - ); + }); + + test('the link was open if and only if they click the button', () => { + if (reaction.value === undefined) { + assert(openExternalStub.notCalled); + } + if (reaction.value) { + assert(openExternalStub.called); + assert(uriParseStub.called); + assert.strictEqual( + uriParseStub.firstCall.args[0], + 'https://forms.gle/9viN9wcbsC3zvHyg7', + ); + } + }); + + test("it sets that they've been shown the survey", () => { + assert(connectionsUpdateStub.called); + assert.strictEqual( + connectionsUpdateStub.firstCall.args[0], + StorageVariables.GLOBAL_SURVEY_SHOWN + ); + assert.strictEqual( + connectionsUpdateStub.firstCall.args[1], + '9viN9wcbsC3zvHyg7' + ); + }); }); }); } From 2db67af402277d5836063d00b8085c3647a7c0ac Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Tue, 20 Aug 2024 15:51:44 +0200 Subject: [PATCH 6/9] . --- src/test/suite/mdbExtensionController.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 4a7999714..854265ffa 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -1727,8 +1727,11 @@ suite('MDBExtensionController Test Suite', function () { "when a user hasn't been shown the survey prompt yet, and they have connections saved", () => { [ - { description: 'clicked the button', value: { title: 'Share your thoughts' } }, - // { description: 'dismissed', value: undefined }, + { + description: 'clicked the button', + value: { title: 'Share your thoughts' }, + }, + { description: 'dismissed', value: undefined }, ].forEach((reaction) => { suite(`user ${reaction.description}`, () => { let connectionsUpdateStub: SinonStub; @@ -1774,7 +1777,7 @@ suite('MDBExtensionController Test Suite', function () { assert(uriParseStub.called); assert.strictEqual( uriParseStub.firstCall.args[0], - 'https://forms.gle/9viN9wcbsC3zvHyg7', + 'https://forms.gle/9viN9wcbsC3zvHyg7' ); } }); From ebefc43a983e9b2154c734689e307ba1c00a7cf6 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Tue, 20 Aug 2024 17:11:33 +0200 Subject: [PATCH 7/9] Update src/mdbExtensionController.ts Co-authored-by: Rhys --- src/mdbExtensionController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index e2d062993..7be2d2d61 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -826,8 +826,9 @@ export default class MDBExtensionController implements vscode.Disposable { // Show the overview page when it hasn't been show to the // user yet, and they have saved connections // -> they haven't just started using this extension - if (!hasBeenShownSurveyAlready) { - if (this._connectionStorage.hasSavedConnections()) { + if (hasBeenShownSurveyAlready || !this._connectionStorage.hasSavedConnections()) { + return; + } const action = 'Share your thoughts'; const text = 'How can we make the MongoDB extension better for you?'; const link = 'https://forms.gle/9viN9wcbsC3zvHyg7'; From c44baeb82a94aedccbec80be3b2b1962b45cdd2d Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Tue, 20 Aug 2024 17:11:46 +0200 Subject: [PATCH 8/9] Update src/mdbExtensionController.ts Co-authored-by: Rhys --- src/mdbExtensionController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 7be2d2d61..3100a19e3 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -839,7 +839,7 @@ export default class MDBExtensionController implements vscode.Disposable { title: action, } ); - if (result && result.title === action) { + if (result?.title === action) { void vscode.env.openExternal(vscode.Uri.parse(link)); } From 2326a7511421580c5f529668221032a225832f7a Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Tue, 20 Aug 2024 12:31:59 -0400 Subject: [PATCH 9/9] fixup: move stub location, fix indents --- src/mdbExtensionController.ts | 40 ++++++++++--------- src/test/suite/mdbExtensionController.test.ts | 4 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 3100a19e3..78b9cb741 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -826,30 +826,32 @@ export default class MDBExtensionController implements vscode.Disposable { // Show the overview page when it hasn't been show to the // user yet, and they have saved connections // -> they haven't just started using this extension - if (hasBeenShownSurveyAlready || !this._connectionStorage.hasSavedConnections()) { + if ( + hasBeenShownSurveyAlready || + !this._connectionStorage.hasSavedConnections() + ) { return; } - const action = 'Share your thoughts'; - const text = 'How can we make the MongoDB extension better for you?'; - const link = 'https://forms.gle/9viN9wcbsC3zvHyg7'; - const result = await vscode.window.showInformationMessage( - text, - {}, - { - title: action, - } - ); - if (result?.title === action) { - void vscode.env.openExternal(vscode.Uri.parse(link)); - } - // whether action was taken or the prompt dismissed, we won't show this again - void this._storageController.update( - StorageVariables.GLOBAL_SURVEY_SHOWN, - surveyId - ); + const action = 'Share your thoughts'; + const text = 'How can we make the MongoDB extension better for you?'; + const link = 'https://forms.gle/9viN9wcbsC3zvHyg7'; + const result = await vscode.window.showInformationMessage( + text, + {}, + { + title: action, } + ); + if (result?.title === action) { + void vscode.env.openExternal(vscode.Uri.parse(link)); } + + // whether action was taken or the prompt dismissed, we won't show this again + void this._storageController.update( + StorageVariables.GLOBAL_SURVEY_SHOWN, + surveyId + ); } async dispose(): Promise { diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 854265ffa..e887485b9 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -176,7 +176,6 @@ suite('MDBExtensionController Test Suite', function () { let showErrorMessageStub: SinonStub; let fakeCreatePlaygroundFileWithContent: SinonSpy; let openExternalStub: SinonStub; - let uriParseStub: SinonStub; const sandbox = sinon.createSandbox(); @@ -186,7 +185,6 @@ suite('MDBExtensionController Test Suite', function () { 'showInformationMessage' ); openExternalStub = sandbox.stub(vscode.env, 'openExternal'); - uriParseStub = sandbox.stub(vscode.Uri, 'parse'); openTextDocumentStub = sandbox.stub(vscode.workspace, 'openTextDocument'); fakeActiveConnectionId = sandbox.fake.returns('tasty_sandwhich'); sandbox.replace( @@ -1735,6 +1733,7 @@ suite('MDBExtensionController Test Suite', function () { ].forEach((reaction) => { suite(`user ${reaction.description}`, () => { let connectionsUpdateStub: SinonStub; + let uriParseStub: SinonStub; beforeEach(async () => { showInformationMessageStub.resolves(reaction.value); openExternalStub.resolves(undefined); @@ -1752,6 +1751,7 @@ suite('MDBExtensionController Test Suite', function () { mdbTestExtension.testExtensionController._storageController, 'update' ); + uriParseStub = sandbox.stub(vscode.Uri, 'parse'); connectionsUpdateStub.resolves(undefined); await mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); });