Skip to content

Commit

Permalink
PR feedback - changed misleading comment, added a test for verifying …
Browse files Browse the repository at this point in the history
…that no notification / tracking was sent if the failed migrations are not from current load of extension
  • Loading branch information
himanshusinghs committed Jul 5, 2023
1 parent 1249543 commit 24bfe9e
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion src/test/suite/connectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ suite('Connection Controller Test Suite', function () {
);
const trackStub = testSandbox.stub(testTelemetryService, 'track');

// Load the connections
// Clear any connections and load so we get our stubbed connections from above.
testConnectionController.clearAllConnections();
await testConnectionController.loadSavedConnections();
const [, secondConnection] =
Expand All @@ -1539,5 +1539,59 @@ suite('Connection Controller Test Suite', function () {
{ totalConnections: 2, connectionsWithFailedKeytarMigration: 1 },
]);
});

test('should neither track not notify the user if none of the failed migrations are from current load of extension', async () => {
testSandbox.replace(testStorageController, 'get', (key, storage) => {
if (
storage === StorageLocation.WORKSPACE ||
key === StorageVariables.WORKSPACE_SAVED_CONNECTIONS
) {
return {};
}

return {
'random-connection-1': {
id: 'random-connection-1',
name: 'localhost:27017',
storageLocation: 'GLOBAL',
secretStorageLocation: SecretStorageLocation.Keytar,
connectionOptions: {
connectionString:
'mongodb://localhost:27017/?readPreference=primary&ssl=false',
},
},
'random-connection-2': {
id: 'random-connection-2',
name: 'localhost:27018',
storageLocation: 'GLOBAL',
secretStorageLocation: SecretStorageLocation.Keytar,
connectionOptions: {
connectionString:
'mongodb://localhost:27018/?readPreference=primary&ssl=false',
},
},
} as any;
});
testSandbox.replace(
testConnectionController,
'_getConnectionInfoWithSecrets',
(connectionInfo) =>
Promise.resolve({
...connectionInfo,
secretStorageLocation: SecretStorageLocation.Keytar,
} as any)
);
const trackStub = testSandbox.stub(testTelemetryService, 'track');

// Clear any connections and load so we get our stubbed connections from above.
testConnectionController.clearAllConnections();
await testConnectionController.loadSavedConnections();

// No notification sent to the user
assert.strictEqual(showInformationMessageStub.notCalled, true);

// No tracking done
assert.strictEqual(trackStub.notCalled, true);
});
});
});

0 comments on commit 24bfe9e

Please sign in to comment.