Create untitled notebook names in core code rather than in the notebook extension (#21111)

This commit is contained in:
Cory Rivera
2022-11-04 19:31:55 -07:00
committed by GitHub
parent a618ef983a
commit facd317b4d
9 changed files with 63 additions and 94 deletions

View File

@@ -50,12 +50,12 @@ describe('notebookUtils Tests', function (): void {
should(azdata.nb.notebookDocuments.length).equal(0, 'There should be not any open Notebook documents');
await notebookUtils.newNotebook(undefined);
should(azdata.nb.notebookDocuments.length).equal(1, 'There should be exactly 1 open Notebook document');
should(azdata.nb.notebookDocuments[0].fileName).equal('Notebook-0', 'The first Untitled Notebook should have an index of 0');
should(azdata.nb.notebookDocuments[0].fileName).equal('Notebook-1', 'The first Untitled Notebook should have an index of 1');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
should(azdata.nb.notebookDocuments.length).equal(0, 'There should be not any open Notebook documents');
await notebookUtils.newNotebook(undefined);
should(azdata.nb.notebookDocuments.length).equal(1, 'There should be exactly 1 open Notebook document after second opening');
should(azdata.nb.notebookDocuments[0].fileName).equal('Notebook-0', 'The first Untitled Notebook should have an index of 0 after closing first Untitled Notebook');
should(azdata.nb.notebookDocuments[0].fileName).equal('Notebook-1', 'The first Untitled Notebook should have an index of 1 after closing first Untitled Notebook');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
});
@@ -65,7 +65,7 @@ describe('notebookUtils Tests', function (): void {
should(azdata.nb.notebookDocuments.length).equal(1, 'There should be exactly 1 open Notebook document');
const secondNotebook = await notebookUtils.newNotebook(undefined);
should(azdata.nb.notebookDocuments.length).equal(2, 'There should be exactly 2 open Notebook documents');
should(secondNotebook.document.fileName).equal('Notebook-1', 'The second Untitled Notebook should have an index of 1');
should(secondNotebook.document.fileName).equal('Notebook-2', 'The second Untitled Notebook should have an index of 2');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
should(azdata.nb.notebookDocuments.length).equal(0, 'There should be not any open Notebook documents');

View File

@@ -10,7 +10,6 @@ import * as os from 'os';
import * as path from 'path';
import * as utils from '../../common/utils';
import { MockOutputChannel } from './stubs';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import { sleep } from './testUtils';
@@ -274,37 +273,6 @@ describe('Utils Tests', function () {
});
});
describe('isEditorTitleFree', () => {
afterEach(async () => {
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
});
it('title is free', () => {
should(utils.isEditorTitleFree('MyTitle')).be.true();
});
it('title is not free with text document sharing name', async () => {
const editorTitle = 'Untitled-1';
should(utils.isEditorTitleFree(editorTitle)).be.true('Title should be free before opening text document');
await vscode.workspace.openTextDocument();
should(utils.isEditorTitleFree(editorTitle)).be.false('Title should not be free after opening text document');
});
it('title is not free with notebook document sharing name', async () => {
const editorTitle = 'MyUntitledNotebook';
should(utils.isEditorTitleFree(editorTitle)).be.true('Title should be free before opening notebook');
await azdata.nb.showNotebookDocument(vscode.Uri.parse(`untitled:${editorTitle}`));
should(utils.isEditorTitleFree('MyUntitledNotebook')).be.false('Title should not be free after opening notebook');
});
it('title is not free with notebook document sharing name created through command', async () => {
const editorTitle = 'Notebook-0';
should(utils.isEditorTitleFree(editorTitle)).be.true('Title should be free before opening notebook');
await vscode.commands.executeCommand('_notebook.command.new');
should(utils.isEditorTitleFree(editorTitle)).be.false('Title should not be free after opening notebook');
});
});
describe('getClusterEndpoints', () => {
const baseServerInfo: azdata.ServerInfo = {
serverMajorVersion: -1,