rewrite some automation; add notebook tests (#10853)

This commit is contained in:
Anthony Dresser
2020-06-11 13:17:10 -07:00
committed by GitHub
parent f862d77f34
commit 6b86cbdd6e
6 changed files with 57 additions and 13 deletions

View File

@@ -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<void> {
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');
}
}

View File

@@ -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<void> {
await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${INDEX}', '' + index));
public async run(): Promise<void> {
await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${CLASS}', 'start'));
}
public async waitForButton(index: number, label: string): Promise<void> {
await this.code.waitForTextContent(CommandBar.COMMAND_BAR_BUTTON.replace('${INDEX}', '' + index), label);
public async connect(): Promise<void> {
await this.code.waitAndClick(CommandBar.COMMAND_BAR_BUTTON.replace('${CLASS}', 'connect'));
}
}

View File

@@ -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);
}

View File

@@ -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');
});
});
}

View File

@@ -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');
});
});
}

View File

@@ -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 */