diff --git a/src/sql/workbench/contrib/notebook/test/electron-browser/notebookModel.test.ts b/src/sql/workbench/contrib/notebook/test/electron-browser/notebookModel.test.ts index 40cebf0c13..73e883ee3f 100644 --- a/src/sql/workbench/contrib/notebook/test/electron-browser/notebookModel.test.ts +++ b/src/sql/workbench/contrib/notebook/test/electron-browser/notebookModel.test.ts @@ -829,6 +829,42 @@ suite('notebook model', function (): void { assert.ok(spy.calledWith(connectionName, expectedConnectionProfile)); }); + test('should read and write multi_connection_mode to notebook metadata correctly', async function () { + // Given a notebook with multi_connection_mode: true in metadata + let notebook: nb.INotebookContents = { + cells: [], + metadata: { + multi_connection_mode: true + }, + nbformat: 4, + nbformat_minor: 5 + }; + let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentManager); + mockContentManager.setup(c => c.loadContent()).returns(() => Promise.resolve(notebook)); + defaultModelOptions.contentManager = mockContentManager.object; + + // When I initialize the model + let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService); + await model.loadContents(); + + // I expect multiConnectionMode to be set to true + assert.equal(model.multiConnectionMode, true, 'multi_connection_mode not read correctly from notebook metadata'); + + // When I change multiConnectionMode to false + model.multiConnectionMode = false; + + // I expect multi_connection_mode to not be in the notebook metadata + let output: nb.INotebookContents = model.toJSON(); + assert.equal(output.metadata['multi_connection_mode'], undefined, 'multi_connection_mode saved in notebook metadata when it should not be'); + + // When I change multiConnectionMode to true + model.multiConnectionMode = true; + + // I expect multi_connection_mode to be in the notebook metadata + output = model.toJSON(); + assert.equal(output.metadata['multi_connection_mode'], true, 'multi_connection_mode not saved correctly to notebook metadata'); + }); + async function loadModelAndStartClientSession(): Promise { let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentManager); mockContentManager.setup(c => c.loadContent()).returns(() => Promise.resolve(expectedNotebookContent));