Add and fix Notebook tests (#10488)

* Add and fix Notebook tests

* Fix name

* Fix compile

* Acutally fix error

* Add Notebook title test and fix command

* Add extra check and add comments

* Remove extra show error message
This commit is contained in:
Charles Gagnon
2020-05-26 17:27:43 -07:00
committed by GitHub
parent 8f33e1c4c0
commit 7496d09eb9
5 changed files with 197 additions and 16 deletions

View File

@@ -54,12 +54,12 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
});
});
}));
extensionContext.subscriptions.push(vscode.commands.registerCommand('_notebook.command.new', (context?: azdata.ConnectedContext) => {
extensionContext.subscriptions.push(vscode.commands.registerCommand('_notebook.command.new', async (context?: azdata.ConnectedContext) => {
let connectionProfile: azdata.IConnectionProfile = undefined;
if (context && context.connectionProfile) {
connectionProfile = context.connectionProfile;
}
newNotebook(connectionProfile);
return newNotebook(connectionProfile);
}));
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.open', async () => {
await openNotebook();
@@ -142,10 +142,10 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
};
}
function newNotebook(connectionProfile: azdata.IConnectionProfile) {
let title = findNextUntitledEditorName();
let untitledUri = vscode.Uri.parse(`untitled:${title}`);
let options: azdata.nb.NotebookShowOptions = connectionProfile ? {
async function newNotebook(connectionProfile: azdata.IConnectionProfile): Promise<azdata.nb.NotebookEditor> {
const title = findNextUntitledEditorName();
const untitledUri = vscode.Uri.parse(`untitled:${title}`);
const options: azdata.nb.NotebookShowOptions = connectionProfile ? {
viewColumn: null,
preserveFocus: true,
preview: null,
@@ -153,11 +153,7 @@ function newNotebook(connectionProfile: azdata.IConnectionProfile) {
connectionProfile: connectionProfile,
defaultKernel: null
} : null;
azdata.nb.showNotebookDocument(untitledUri, options).then(success => {
}, (err: Error) => {
vscode.window.showErrorMessage(err.message);
});
return azdata.nb.showNotebookDocument(untitledUri, options);
}
function findNextUntitledEditorName(): string {