From 6b86cbdd6ea0c8781812270d01a3fff1454ecf0c Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Thu, 11 Jun 2020 13:17:10 -0700 Subject: [PATCH] rewrite some automation; add notebook tests (#10853) --- test/automation/src/sql/notebook.ts | 24 +++++++++++++++++++ test/automation/src/sql/queryEditor.ts | 10 ++++---- test/automation/src/workbench.ts | 3 +++ .../src/sql/areas/notebook/notebook.test.ts | 15 ++++++++++++ .../sql/areas/queryEditor/queryEditor.test.ts | 12 +++++----- test/smoke/src/sql/main.ts | 6 +++-- 6 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 test/automation/src/sql/notebook.ts create mode 100644 test/smoke/src/sql/areas/notebook/notebook.test.ts diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts new file mode 100644 index 0000000000..fb98f24041 --- /dev/null +++ b/test/automation/src/sql/notebook.ts @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Code } from '../code'; +import { QuickAccess } from '../quickaccess'; +import { QuickInput } from '../quickinput'; +import { Editors } from '../editors'; + +export class Notebook { + + constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) { + } + + async openFile(fileName: string): Promise { + await this.quickAccess.openQuickAccess(fileName); + + await this.quickInput.waitForQuickInputElements(names => names[0] === fileName); + await this.code.dispatchKeybinding('enter'); + await this.editors.waitForActiveTab(fileName); + await this.code.waitForElement('.notebookEditor'); + } +} diff --git a/test/automation/src/sql/queryEditor.ts b/test/automation/src/sql/queryEditor.ts index 72c5d4a2c0..0e07674db1 100644 --- a/test/automation/src/sql/queryEditor.ts +++ b/test/automation/src/sql/queryEditor.ts @@ -21,15 +21,15 @@ export class QueryEditor { export class CommandBar { - private static readonly COMMAND_BAR_BUTTON = '.query-editor .carbon-taskbar ul>:nth-child(${INDEX})'; + private static readonly COMMAND_BAR_BUTTON = '.query-editor .carbon-taskbar li .${CLASS}'; constructor(private code: Code) { } - public async clickButton(index: number): Promise { - await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${INDEX}', '' + index)); + public async run(): Promise { + await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${CLASS}', 'start')); } - public async waitForButton(index: number, label: string): Promise { - await this.code.waitForTextContent(CommandBar.COMMAND_BAR_BUTTON.replace('${INDEX}', '' + index), label); + public async connect(): Promise { + await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${CLASS}', 'connect')); } } diff --git a/test/automation/src/workbench.ts b/test/automation/src/workbench.ts index abf7855b2b..887103d635 100644 --- a/test/automation/src/workbench.ts +++ b/test/automation/src/workbench.ts @@ -26,6 +26,7 @@ import { ConnectionDialog } from './sql/connectionDialog'; import { Profiler } from './sql/profiler'; import { QueryEditors } from './sql/queryEditors'; import { QueryEditor } from './sql/queryEditor'; +import { Notebook as SqlNotebook } from './sql/notebook'; // {{END}} export interface Commands { @@ -56,6 +57,7 @@ export class Workbench { readonly profiler: Profiler; readonly queryEditors: QueryEditors; readonly queryEditor: QueryEditor; + readonly sqlNotebbok: SqlNotebook; // {{END}} constructor(code: Code, userDataPath: string) { @@ -79,6 +81,7 @@ export class Workbench { this.profiler = new Profiler(code, this.quickaccess); this.queryEditors = new QueryEditors(code, this.editors); this.queryEditor = new QueryEditor(code); + this.sqlNotebbok = new SqlNotebook(code, this.quickaccess, this.quickinput, this.editors); // {{END}} this.notebook = new Notebook(this.quickaccess, code); } diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts new file mode 100644 index 0000000000..0baaf1e0ed --- /dev/null +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Application } from '../../../../../automation'; + +export function setup() { + describe('Notebook', () => { + it('open ', async function () { + const app = this.app as Application; + await app.workbench.sqlNotebbok.openFile('hello.ipynb'); + }); + }); +} diff --git a/test/smoke/src/sql/areas/queryEditor/queryEditor.test.ts b/test/smoke/src/sql/areas/queryEditor/queryEditor.test.ts index 49aa901a9c..371e7434e9 100644 --- a/test/smoke/src/sql/areas/queryEditor/queryEditor.test.ts +++ b/test/smoke/src/sql/areas/queryEditor/queryEditor.test.ts @@ -11,14 +11,14 @@ export function setup() { it('can open, connect and execute file', async function () { const app = this.app as Application; await app.workbench.quickaccess.openFile('test.sql'); - await app.workbench.queryEditor.commandBar.clickButton(3); + await app.workbench.queryEditor.commandBar.connect(); await app.workbench.connectionDialog.waitForConnectionDialog(); await app.workbench.connectionDialog.setProvider('Sqlite'); await app.workbench.connectionDialog.setTarget('File', 'chinook.db'); await app.workbench.connectionDialog.connect(); - await app.workbench.queryEditor.commandBar.clickButton(1); + await app.workbench.queryEditor.commandBar.run(); await app.workbench.queryEditor.waitForResults(); - await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); + await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors'); }); it('can new file, connect and execute', async function () { @@ -26,14 +26,14 @@ export function setup() { await app.workbench.queryEditors.newUntitledQuery(); const untitled = 'SQLQuery_1'; await app.workbench.editor.waitForTypeInEditor(untitled, 'select * from employees'); - await app.workbench.queryEditor.commandBar.clickButton(3); + await app.workbench.queryEditor.commandBar.connect(); await app.workbench.connectionDialog.waitForConnectionDialog(); await app.workbench.connectionDialog.setProvider('Sqlite'); await app.workbench.connectionDialog.setTarget('File', 'chinook.db'); await app.workbench.connectionDialog.connect(); - await app.workbench.queryEditor.commandBar.clickButton(1); + await app.workbench.queryEditor.commandBar.run(); await app.workbench.queryEditor.waitForResults(); - await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); + await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors'); }); }); } diff --git a/test/smoke/src/sql/main.ts b/test/smoke/src/sql/main.ts index 84864b4a30..9100e43541 100644 --- a/test/smoke/src/sql/main.ts +++ b/test/smoke/src/sql/main.ts @@ -3,7 +3,8 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setup as setupQueryEditorTest } from './areas/queryEditor/queryEditor.test'; +import { setup as setupQueryEditorTests } from './areas/queryEditor/queryEditor.test'; +import { setup as setupNotebookTests } from './areas/notebook/notebook.test'; import { ApplicationOptions } from '../../../automation'; import * as yazl from 'yauzl'; import * as fs from 'fs'; @@ -12,7 +13,8 @@ import { request } from 'https'; import * as mkdirp from 'mkdirp'; export function main(): void { - setupQueryEditorTest(); + setupQueryEditorTests(); + setupNotebookTests(); } /* eslint-disable no-sync */