mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fixes notebook integration tests + running parameterized notebook (#15107)
* fix interface * fix run all cells on new parameterized notebook * add getNotebookUri function
This commit is contained in:
@@ -55,7 +55,7 @@ suite('Notebook integration test suite', function () {
|
|||||||
assert(actualOutput2[0] === '1', `Expected result: 1, Actual: '${actualOutput2[0]}'`);
|
assert(actualOutput2[0] === '1', `Expected result: 1, Actual: '${actualOutput2[0]}'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('Sql NB multiple cells test', async function () {
|
test('Sql NB multiple cells test', async function () {
|
||||||
let notebook = await openNotebook(sqlNotebookMultipleCellsContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
let notebook = await openNotebook(sqlNotebookMultipleCellsContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
||||||
await runCells(notebook);
|
await runCells(notebook);
|
||||||
const expectedOutput0 = '(1 row affected)';
|
const expectedOutput0 = '(1 row affected)';
|
||||||
@@ -84,7 +84,7 @@ suite('Notebook integration test suite', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('Sql NB run cells above and below test', async function () {
|
test('Sql NB run cells above and below test', async function () {
|
||||||
let notebook = await openNotebook(sqlNotebookMultipleCellsContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
let notebook = await openNotebook(sqlNotebookMultipleCellsContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
||||||
// When running all cells above a cell, ensure that only cells preceding current cell have output
|
// When running all cells above a cell, ensure that only cells preceding current cell have output
|
||||||
await runCells(notebook, true, undefined, notebook.document.cells[1]);
|
await runCells(notebook, true, undefined, notebook.document.cells[1]);
|
||||||
@@ -101,13 +101,13 @@ suite('Notebook integration test suite', function () {
|
|||||||
assert(notebook.document.cells[2].contents.outputs.length === 3, `Expected length: '3', Actual: '${notebook.document.cells[2].contents.outputs.length}'`);
|
assert(notebook.document.cells[2].contents.outputs.length === 3, `Expected length: '3', Actual: '${notebook.document.cells[2].contents.outputs.length}'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('Clear cell output - SQL notebook', async function () {
|
test('Clear cell output - SQL notebook', async function () {
|
||||||
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
||||||
await runCell(notebook);
|
await runCell(notebook);
|
||||||
await verifyClearOutputs(notebook);
|
await verifyClearOutputs(notebook);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('Clear all outputs - SQL notebook', async function () {
|
test('Clear all outputs - SQL notebook', async function () {
|
||||||
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title + this.invocationCount++);
|
||||||
await runCell(notebook);
|
await runCell(notebook);
|
||||||
await verifyClearAllOutputs(notebook);
|
await verifyClearAllOutputs(notebook);
|
||||||
@@ -128,7 +128,7 @@ suite('Notebook integration test suite', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('should not be dirty after saving notebook test', async function () {
|
test('should not be dirty after saving notebook test', async function () {
|
||||||
// Given a notebook that's been edited (in this case, open notebook runs the 1st cell and adds an output)
|
// Given a notebook that's been edited (in this case, open notebook runs the 1st cell and adds an output)
|
||||||
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title);
|
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata, this.test.title);
|
||||||
await runCell(notebook);
|
await runCell(notebook);
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { IContentManager } from 'sql/workbench/services/notebook/browser/models/
|
|||||||
import { IStandardKernelWithProvider } from 'sql/workbench/services/notebook/browser/models/notebookUtils';
|
import { IStandardKernelWithProvider } from 'sql/workbench/services/notebook/browser/models/notebookUtils';
|
||||||
|
|
||||||
export interface INotebookInput {
|
export interface INotebookInput {
|
||||||
defaultKernel: azdata.nb.IKernelSpec,
|
defaultKernel?: azdata.nb.IKernelSpec,
|
||||||
connectionProfile: azdata.IConnectionProfile,
|
connectionProfile?: azdata.IConnectionProfile,
|
||||||
isDirty(): boolean;
|
isDirty(): boolean;
|
||||||
setDirty(boolean);
|
setDirty(boolean);
|
||||||
readonly notebookUri: URI;
|
readonly notebookUri: URI;
|
||||||
@@ -22,12 +22,13 @@ export interface INotebookInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isINotebookInput(value: any): value is INotebookInput {
|
export function isINotebookInput(value: any): value is INotebookInput {
|
||||||
if (typeof value.defaultKernel === 'object' &&
|
if (
|
||||||
typeof value.connectionProfile === 'object' &&
|
(typeof value.defaultKernel === 'object' || value.defaultKernel === undefined) &&
|
||||||
typeof value.isDirty === 'boolean' &&
|
(typeof value.connectionProfile === 'object' || value.connectionProfile === undefined) &&
|
||||||
value.notebookUri instanceof URI &&
|
typeof value.notebookUri === 'object' &&
|
||||||
|
typeof value.isDirty === 'function' &&
|
||||||
|
typeof value.layoutChanged === 'function' &&
|
||||||
typeof value.editorOpenedTimestamp === 'number' &&
|
typeof value.editorOpenedTimestamp === 'number' &&
|
||||||
typeof value.layoutChanged === 'object' &&
|
|
||||||
typeof value.contentManager === 'object' &&
|
typeof value.contentManager === 'object' &&
|
||||||
typeof value.standardKernels === 'object') {
|
typeof value.standardKernels === 'object') {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -407,8 +407,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
if (!notebookUri) {
|
if (!notebookUri) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
// The NotebookEditor will not be found if there is query or fragments attached to the URI
|
let uriString = getNotebookUri(notebookUri);
|
||||||
let uriString = notebookUri.with({ query: '', fragment: '' }).toString();
|
|
||||||
let editor = this.listNotebookEditors().find(n => n.id === uriString);
|
let editor = this.listNotebookEditors().find(n => n.id === uriString);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
@@ -707,3 +706,16 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
this._onCodeCellExecutionStart.fire();
|
this._onCodeCellExecutionStart.fire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Untitled notebookUri's need to have the query in order to get the NotebookEditor to run other actions (Run All Cells for example) on parameterized notebooks
|
||||||
|
* otherwise we strip the query and fragment from the notebookUri for all other file schemes
|
||||||
|
* @param notebookUri of the notebook
|
||||||
|
* @returns uriString that contains the formatted notebookUri
|
||||||
|
*/
|
||||||
|
export function getNotebookUri(notebookUri: URI): string {
|
||||||
|
if (notebookUri.scheme === 'untitled') {
|
||||||
|
return notebookUri.toString();
|
||||||
|
}
|
||||||
|
return notebookUri.with({ query: '', fragment: '' }).toString();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user