Add simple notebook code cell smoke test (#15870)

* simple code cell test

* change test order

* fix select all text keybinding
This commit is contained in:
Lucy Zhang
2021-06-22 23:31:53 -04:00
committed by GitHub
parent 3634110974
commit c636e24d03
2 changed files with 66 additions and 57 deletions

View File

@@ -104,7 +104,7 @@ export class Notebook {
public async selectAllTextInEditor(): Promise<void> {
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';

View File

@@ -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<v
await app.workbench.sqlNotebook.openFile(filename);
await app.workbench.sqlNotebook.waitForKernel('Python 3');
await app.workbench.sqlNotebook.waitForAllResults();
await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor');
}