From c636e24d037463ea3d4eac2130701140b400f2b0 Mon Sep 17 00:00:00 2001 From: Lucy Zhang Date: Tue, 22 Jun 2021 23:31:53 -0400 Subject: [PATCH] Add simple notebook code cell smoke test (#15870) * simple code cell test * change test order * fix select all text keybinding --- test/automation/src/sql/notebook.ts | 2 +- .../src/sql/areas/notebook/notebook.test.ts | 121 ++++++++++-------- 2 files changed, 66 insertions(+), 57 deletions(-) diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index 5b12df7d0b..a202bc4cf6 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -104,7 +104,7 @@ export class Notebook { public async selectAllTextInEditor(): Promise { const editor = '.notebook-cell.active .monaco-editor'; await this.code.waitAndClick(editor); - await this.code.dispatchKeybinding('ctrl+a'); + await this.code.dispatchKeybinding('cmd+a'); } private static readonly placeholderSelector = 'div.placeholder-cell-component'; diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index cf9c56334a..90a6192e9f 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -8,60 +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(); - await app.workbench.sqlNotebook.addCell('code'); - await app.workbench.sqlNotebook.waitForTypeInEditor('print("Hello world!")'); - await app.workbench.sqlNotebook.waitForKernel('SQL'); - - await app.workbench.sqlNotebook.changeKernel('Python 3'); - await app.workbench.configurePythonDialog.waitForConfigurePythonDialog(); - await app.workbench.configurePythonDialog.installPython(); - await app.workbench.sqlNotebook.waitForKernel('Python 3'); - - await app.workbench.sqlNotebook.runActiveCell(); - await app.workbench.sqlNotebook.waitForActiveCellResults(); - - await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor'); - }); - - it('can open ipynb file, run all, and save notebook with outputs', async function () { - const app = this.app as Application; - await openAndRunNotebook(app, 'hello.ipynb'); - }); - - it('can open ipynb file from path with spaces, run all, and save notebook with outputs', async function () { - const app = this.app as Application; - await openAndRunNotebook(app, 'helloWithSpaces.ipynb'); - }); - - it('can open ipynb file from path with escaped spaces, run all, and save notebook with outputs', async function () { - const app = this.app as Application; - await openAndRunNotebook(app, 'helloWithEscapedSpaces.ipynb'); - }); - - it('can open untrusted notebook, trust, save, and reopen trusted notebook', async function () { - const app = this.app as Application; - await app.workbench.sqlNotebook.openFile('untrusted.ipynb'); - await app.workbench.sqlNotebook.waitForKernel('SQL'); - await app.workbench.sqlNotebook.waitForNotTrustedIcon(); - await app.workbench.sqlNotebook.waitForTrustedElementsGone(); - - await app.workbench.sqlNotebook.trustNotebook(); - await app.workbench.sqlNotebook.waitForTrustedIcon(); - await app.workbench.sqlNotebook.waitForTrustedElements(); - - await app.workbench.quickaccess.runCommand('workbench.action.files.save'); - await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); - - await app.workbench.sqlNotebook.openFile('untrusted.ipynb'); - await app.workbench.sqlNotebook.waitForTrustedIcon(); - await app.workbench.sqlNotebook.waitForTrustedElements(); - - await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); - }); - it('can perform basic text cell functionality', async function () { const app = this.app as Application; await app.workbench.sqlNotebook.newUntitledNotebook(); @@ -80,7 +26,72 @@ export function setup() { await app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(); await app.code.dispatchKeybinding('escape'); await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p', 'strong'); + }); + it('can perform basic code cell functionality', async function () { + const app = this.app as Application; + await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.addCellFromPlaceholder('Code'); + await app.workbench.sqlNotebook.waitForPlaceholderGone(); + + const sampleText: string = 'SELECT * FROM sys.tables'; + await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText); + }); + + it('can open untrusted notebook, trust, save, and reopen trusted notebook', async function () { + const app = this.app as Application; + await app.workbench.sqlNotebook.openFile('untrusted.ipynb'); + await app.workbench.sqlNotebook.waitForKernel('SQL'); + await app.workbench.sqlNotebook.waitForNotTrustedIcon(); + await app.workbench.sqlNotebook.waitForTrustedElementsGone(); + + await app.workbench.sqlNotebook.trustNotebook(); + await app.workbench.sqlNotebook.waitForTrustedIcon(); + await app.workbench.sqlNotebook.waitForTrustedElements(); + + await app.workbench.quickaccess.runCommand('workbench.action.files.save'); + await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); + + await app.workbench.sqlNotebook.openFile('untrusted.ipynb'); + await app.workbench.sqlNotebook.waitForTrustedIcon(); + await app.workbench.sqlNotebook.waitForTrustedElements(); + }); + + // Python Notebooks + + it('can open new notebook, configure Python, and execute one cell', async function () { + const app = this.app as Application; + await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.addCell('code'); + await app.workbench.sqlNotebook.waitForTypeInEditor('print("Hello world!")'); + await app.workbench.sqlNotebook.waitForKernel('SQL'); + + await app.workbench.sqlNotebook.changeKernel('Python 3'); + await app.workbench.configurePythonDialog.waitForConfigurePythonDialog(); + await app.workbench.configurePythonDialog.installPython(); + await app.workbench.sqlNotebook.waitForKernel('Python 3'); + + await app.workbench.sqlNotebook.runActiveCell(); + 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 openAndRunNotebook(app, 'hello.ipynb'); + }); + + it('can open ipynb file from path with spaces, run all, and save notebook with outputs', async function () { + const app = this.app as Application; + await openAndRunNotebook(app, 'helloWithSpaces.ipynb'); + }); + + it('can open ipynb file from path with escaped spaces, run all, and save notebook with outputs', async function () { + const app = this.app as Application; + await openAndRunNotebook(app, 'helloWithEscapedSpaces.ipynb'); + }); + + afterEach(async function () { + const app = this.app as Application; await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor'); }); }); @@ -101,6 +112,4 @@ async function openAndRunNotebook(app: Application, filename: string): Promise