Add more smoke tests and abstract more code (#10799)

* add more smoke tests and abstract more code

* fix missing imports
This commit is contained in:
Anthony Dresser
2020-06-10 12:12:35 -07:00
committed by GitHub
parent 187667f4f1
commit d849ed9357
6 changed files with 43 additions and 29 deletions

View File

@@ -9,10 +9,14 @@ export class QueryEditor {
public readonly commandBar: CommandBar;
constructor(code: Code) {
constructor(private code: Code) {
this.commandBar = new CommandBar(code);
}
private static readonly RESULT_SELECTOR = '.query-editor-view .monaco-table';
public async waitForResults(): Promise<void> {
await this.code.waitForElement(QueryEditor.RESULT_SELECTOR);
}
}
export class CommandBar {

View File

@@ -6,32 +6,21 @@
import { Editors } from '../editors';
import { Code } from '../code';
export class QueryEditors extends Editors {
export class QueryEditors {
constructor(
private vsCode: Code
private readonly code: Code,
private readonly editors: Editors
) {
super(vsCode);
}
/**
* Waits for an active SQL Query Editor tab for the specified file. This is a modification of the editors.waitForActiveTab that
* takes into account the connected status displayed in the title of Query Editors.
* @param fileName The name of the file opened in the editor
* @param isDirty Whether the file is dirty or not
*/
async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<void> {
// For now assume all opened tabs are disconnected until we have a need to open connected tabs
await this.vsCode.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName} - disconnected, tab"]`);
}
async newUntitledQuery(): Promise<void> {
if (process.platform === 'darwin') {
await this.code.dispatchKeybinding('cmd+n');
} else {
await this.code.dispatchKeybinding('ctrl+n');
}
/**
* Waits for an active Query Editor for the specified file to have focus. This is a modification of the editors.waitForEditorFocus
* that takes into account the connected status displayed in the title of Query Editors.
* @param fileName The name of the file opened in the editor
*/
async waitForEditorFocus(fileName: string): Promise<void> {
await this.waitForActiveTab(fileName);
await super.waitForActiveEditor(fileName);
await this.editors.waitForEditorFocus('SQLQuery_1');
}
}