+
diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts
index 5a605c508d..6872fe378c 100644
--- a/test/automation/src/sql/notebook.ts
+++ b/test/automation/src/sql/notebook.ts
@@ -58,6 +58,12 @@ export class Notebook {
await this.code.dispatchKeybinding(winOrCtrl + '+shift+F5');
}
+ async clearResults(): Promise {
+ await this.code.waitAndClick('.notebookEditor');
+ const clearResultsButton = '.editor-toolbar a[class="action-label codicon notebook-button icon-clear-results masked-icon"]';
+ await this.code.waitAndClick(clearResultsButton);
+ }
+
async waitForTypeInEditor(text: string) {
const editor = '.notebook-cell.active .monaco-editor';
await this.code.waitAndClick(editor);
@@ -74,10 +80,45 @@ export class Notebook {
return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' ')));
}
- async waitForResults(): Promise {
+ async waitForActiveCellResults(): Promise {
const outputComponent = '.notebook-cell.active .notebook-output';
await this.code.waitForElement(outputComponent);
}
+
+ async waitForResults(cellIds: string[]): Promise {
+ for (let i of cellIds) {
+ await this.code.waitForElement(`div.notebook-cell[id="${i}"] .notebook-output`);
+ }
+ }
+
+ async waitForAllResults(): Promise {
+ let cellIds: string[] = [];
+ await this.code.waitForElements('div.notebook-cell', false, result => {
+ cellIds = result.map(cell => cell.attributes['id']);
+ return true;
+ });
+ await this.waitForResults(cellIds);
+ }
+
+ async waitForActiveCellResultsGone(): Promise {
+ const outputComponent = '.notebook-cell.active .notebook-output';
+ await this.code.waitForElementGone(outputComponent);
+ }
+
+ async waitForResultsGone(cellIds: string[]): Promise {
+ for (let i of cellIds) {
+ await this.code.waitForElementGone(`div.notebook-cell[id="${i}"] .notebook-output`);
+ }
+ }
+
+ async waitForAllResultsGone(): Promise {
+ let cellIds: string[] = [];
+ await this.code.waitForElements('div.notebook-cell', false, result => {
+ cellIds = result.map(cell => cell.attributes['id']);
+ return true;
+ });
+ await this.waitForResultsGone(cellIds);
+ }
}
export class NotebookToolbar {
diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts
index 3f88f521ad..9b53a72db8 100644
--- a/test/smoke/src/sql/areas/notebook/notebook.test.ts
+++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts
@@ -8,7 +8,6 @@ import { Application } from '../../../../../automation';
export function setup() {
describe('Notebook', () => {
-
it('can open new notebook, configure Python, and execute one cell', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.newUntitledNotebook();
@@ -21,8 +20,25 @@ export function setup() {
await app.workbench.sqlNotebook.waitForKernel('Python 3');
await app.workbench.sqlNotebook.runActiveCell();
- await app.workbench.sqlNotebook.waitForResults();
+ await app.workbench.sqlNotebook.waitForActiveCellResults();
+ });
+
+ it('can open ipynb file, run all, and save notebook with outputs', async function () {
+ const app = this.app as Application;
+ await app.workbench.sqlNotebook.openFile('hello.ipynb');
+ await app.workbench.sqlNotebook.waitForKernel('Python 3');
+
+ await app.workbench.sqlNotebook.clearResults();
+ await app.workbench.sqlNotebook.waitForAllResultsGone();
+ await app.workbench.sqlNotebook.runAllCells();
+ await app.workbench.sqlNotebook.waitForAllResults();
+
+ await app.workbench.quickaccess.runCommand('workbench.action.files.save');
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
+
+ await app.workbench.sqlNotebook.openFile('hello.ipynb');
+ await app.workbench.sqlNotebook.waitForKernel('Python 3');
+ await app.workbench.sqlNotebook.waitForAllResults();
});
});
}