mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
188
test/smoke/src/areas/common.ts
Normal file
188
test/smoke/src/areas/common.ts
Normal file
@@ -0,0 +1,188 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
import { Util } from '../helpers/utilities';
|
||||
|
||||
/**
|
||||
* Contains methods that are commonly used across test areas.
|
||||
*/
|
||||
export class CommonActions {
|
||||
private util: Util;
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
this.util = new Util();
|
||||
}
|
||||
|
||||
public async getWindowTitle(): Promise<any> {
|
||||
return this.spectron.client.getTitle();
|
||||
}
|
||||
|
||||
public enter(): Promise<any> {
|
||||
return this.spectron.client.keys(['Enter', 'NULL']);
|
||||
}
|
||||
|
||||
public async addSetting(setting: string, value: string): Promise<any> {
|
||||
await this.spectron.command('workbench.action.openGlobalSettings');
|
||||
await this.spectron.wait();
|
||||
await this.spectron.client.keys(['ArrowDown', 'NULL', 'ArrowRight', 'NULL'], false);
|
||||
await this.spectron.client.keys(`"${setting}": "${value}"`);
|
||||
await this.spectron.wait();
|
||||
return this.saveOpenedFile();
|
||||
}
|
||||
|
||||
public async newUntitledFile(): Promise<any> {
|
||||
await this.spectron.command('workbench.action.files.newUntitledFile');
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public closeTab(): Promise<any> {
|
||||
return this.spectron.client.keys(['Control', 'w', 'NULL']);
|
||||
}
|
||||
|
||||
public async getTab(tabName: string, active?: boolean): Promise<any> {
|
||||
await this.closeCurrentNotification(); // close any notification messages that could overlap tabs
|
||||
|
||||
let tabSelector = active ? '.tab.active' : 'div';
|
||||
let el = await this.spectron.client.element(`.tabs-container ${tabSelector}[aria-label="${tabName}, tab"]`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async selectTab(tabName: string): Promise<any> {
|
||||
await this.closeCurrentNotification(); // close any notification messages that could overlap tabs
|
||||
return this.spectron.client.click(`.tabs-container div[aria-label="${tabName}, tab"]`);
|
||||
}
|
||||
|
||||
public async openFirstMatchFile(fileName: string): Promise<any> {
|
||||
await this.openQuickOpen();
|
||||
await this.type(fileName);
|
||||
await this.spectron.wait();
|
||||
await this.enter();
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public saveOpenedFile(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.files.save');
|
||||
}
|
||||
|
||||
public type(text: string): Promise<any> {
|
||||
let spectron = this.spectron;
|
||||
|
||||
return new Promise(function (res) {
|
||||
let textSplit = text.split(' ');
|
||||
|
||||
async function type(i: number) {
|
||||
if (!textSplit[i] || textSplit[i].length <= 0) {
|
||||
return res();
|
||||
}
|
||||
|
||||
const toType = textSplit[i + 1] ? `${textSplit[i]} ` : textSplit[i];
|
||||
await spectron.client.keys(toType, false);
|
||||
await spectron.client.keys(['NULL']);
|
||||
await type(i + 1);
|
||||
}
|
||||
|
||||
return type(0);
|
||||
});
|
||||
}
|
||||
|
||||
public showCommands(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.showCommands');
|
||||
}
|
||||
|
||||
public openQuickOpen(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.quickOpen');
|
||||
}
|
||||
|
||||
public closeQuickOpen(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.closeQuickOpen');
|
||||
}
|
||||
|
||||
public selectNextQuickOpenElement(): Promise<any> {
|
||||
return this.spectron.client.keys(['ArrowDown', 'NULL']);
|
||||
}
|
||||
|
||||
public async getQuickOpenElements(): Promise<number> {
|
||||
const elements = await this.spectron.waitFor(this.spectron.client.elements, 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row');
|
||||
return elements.value.length;
|
||||
}
|
||||
|
||||
public async openFile(fileName: string, explorer?: boolean): Promise<any> {
|
||||
let selector = `div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.getExtensionSelector(fileName)}`;
|
||||
if (explorer) {
|
||||
selector += ' explorer-item';
|
||||
}
|
||||
selector += '"]';
|
||||
|
||||
try {
|
||||
await this.spectron.waitFor(this.spectron.client.doubleClick, selector);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Cannot fine ${fileName} in a viewlet.`);
|
||||
}
|
||||
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public getExtensionSelector(fileName: string): string {
|
||||
const extension = fileName.split('.')[1];
|
||||
if (extension === 'js') {
|
||||
return 'js-ext-file-icon javascript-lang-file-icon';
|
||||
} else if (extension === 'json') {
|
||||
return 'json-ext-file-icon json-lang-file-icon';
|
||||
} else if (extension === 'md') {
|
||||
return 'md-ext-file-icon markdown-lang-file-icon';
|
||||
}
|
||||
|
||||
throw new Error('No class defined for this file extension');
|
||||
}
|
||||
|
||||
public async getEditorFirstLinePlainText(): Promise<any> {
|
||||
const trials = 3;
|
||||
let retry = 0;
|
||||
let error;
|
||||
|
||||
while (retry < trials) {
|
||||
try {
|
||||
const span = await this.spectron.client.getText('.view-lines span span');
|
||||
if (Array.isArray(span)) {
|
||||
return span[0];
|
||||
}
|
||||
|
||||
return span;
|
||||
} catch (e) {
|
||||
error = e;
|
||||
retry++;
|
||||
|
||||
if (retry < trials) {
|
||||
await this.spectron.wait();
|
||||
} else {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject('Could not obtain text on the first line of an editor: ' + error);
|
||||
}
|
||||
|
||||
public removeFile(filePath: string): void {
|
||||
this.util.removeFile(filePath);
|
||||
}
|
||||
|
||||
public removeDirectory(directory: string): Promise<any> {
|
||||
try {
|
||||
return this.util.rimraf(directory);
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to remove ${directory} with an error: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
private closeCurrentNotification(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.closeMessages');
|
||||
}
|
||||
}
|
||||
64
test/smoke/src/areas/configuration-views.ts
Normal file
64
test/smoke/src/areas/configuration-views.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export enum ActivityBarPosition {
|
||||
LEFT = 0,
|
||||
RIGHT = 1
|
||||
};
|
||||
|
||||
export class ConfigurationView {
|
||||
// Stores key binding defined for the toggle of activity bar position
|
||||
private keybinding: string[];
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public async getEditorLineNumbers(): Promise<any> {
|
||||
const lineNumbers = await this.spectron.client.elements('.line-numbers');
|
||||
|
||||
return lineNumbers.value.length;
|
||||
}
|
||||
|
||||
public enterKeybindingsView(): any {
|
||||
return this.spectron.command('workbench.action.openGlobalKeybindings');
|
||||
}
|
||||
|
||||
public selectFirstKeybindingsMatch(): any {
|
||||
return this.spectron.waitFor(this.spectron.client.click, 'div[aria-label="Keybindings"] .monaco-list-row.keybinding-item');
|
||||
}
|
||||
|
||||
public changeKeybinding(): any {
|
||||
return this.spectron.command('editor.action.defineKeybinding');
|
||||
}
|
||||
|
||||
public enterBinding(keys: string[]): any {
|
||||
this.keybinding = keys;
|
||||
return this.spectron.client.keys(keys);
|
||||
}
|
||||
|
||||
public toggleActivityBarPosition(): any {
|
||||
return this.spectron.client.keys(this.keybinding);
|
||||
}
|
||||
|
||||
public async getActivityBar(position: ActivityBarPosition) {
|
||||
let positionClass: string;
|
||||
|
||||
if (position === ActivityBarPosition.LEFT) {
|
||||
positionClass = 'left';
|
||||
} else if (position === ActivityBarPosition.RIGHT) {
|
||||
positionClass = 'right';
|
||||
} else {
|
||||
throw new Error('No such position for activity bar defined.');
|
||||
}
|
||||
try {
|
||||
return await this.spectron.waitFor(this.spectron.client.getHTML, `.part.activitybar.${positionClass}`);
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
}
|
||||
62
test/smoke/src/areas/css.ts
Normal file
62
test/smoke/src/areas/css.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export enum CSSProblem {
|
||||
WARNING = 0,
|
||||
ERROR = 1
|
||||
};
|
||||
|
||||
export class CSS {
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public openQuickOutline(): any {
|
||||
return this.spectron.command('workbench.action.gotoSymbol');
|
||||
}
|
||||
|
||||
public toggleProblemsView(): any {
|
||||
return this.spectron.command('workbench.actions.view.problems');
|
||||
}
|
||||
|
||||
public async getEditorProblem(problemType: CSSProblem): Promise<any> {
|
||||
let selector;
|
||||
if (problemType === CSSProblem.WARNING) {
|
||||
selector = 'greensquiggly';
|
||||
} else if (problemType === CSSProblem.ERROR) {
|
||||
selector = 'redsquiggly';
|
||||
} else {
|
||||
throw new Error('No such problem type defined.');
|
||||
}
|
||||
|
||||
let el = await this.spectron.client.element(`.view-overlays .cdr.${selector}`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async getProblemsViewsProblem(problemType: CSSProblem): Promise<any> {
|
||||
let selector;
|
||||
if (problemType === CSSProblem.WARNING) {
|
||||
selector = 'warning';
|
||||
} else if (problemType === CSSProblem.ERROR) {
|
||||
selector = 'error';
|
||||
} else {
|
||||
throw new Error('No such problem type defined.');
|
||||
}
|
||||
|
||||
let el = await this.spectron.client.element(`div[aria-label="Problems grouped by files"] .icon.${selector}`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
26
test/smoke/src/areas/data-loss.ts
Normal file
26
test/smoke/src/areas/data-loss.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export class DataLoss {
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
}
|
||||
|
||||
public openExplorerViewlet(): Promise<any> {
|
||||
return this.spectron.command('workbench.view.explorer');
|
||||
}
|
||||
|
||||
public async verifyTabIsDirty(tabName: string, active?: boolean): Promise<any> {
|
||||
let activeSelector = active ? '.active' : '';
|
||||
let el = await this.spectron.client.element(`.tabs-container .tab.dirty${activeSelector}[aria-label="${tabName}, tab"]`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
112
test/smoke/src/areas/extensions.ts
Normal file
112
test/smoke/src/areas/extensions.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
import { CommonActions } from './common';
|
||||
|
||||
var htmlparser = require('htmlparser2');
|
||||
|
||||
export class Extensions {
|
||||
|
||||
private readonly extensionsViewletSelector = 'div[id="workbench.view.extensions"]';
|
||||
private viewletExtensionIndex: number;
|
||||
|
||||
constructor(private spectron: SpectronApplication, private common: CommonActions) {
|
||||
}
|
||||
|
||||
public async openExtensionsViewlet(): Promise<any> {
|
||||
await this.spectron.command('workbench.view.extensions');
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public async searchForExtension(name: string): Promise<any> {
|
||||
const searchBoxSelector = `${this.extensionsViewletSelector} .search-box`;
|
||||
|
||||
await this.spectron.client.clearElement(searchBoxSelector);
|
||||
try {
|
||||
await this.spectron.client.click(searchBoxSelector, false);
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to click on search box in extensions viewlet.');
|
||||
}
|
||||
await this.spectron.client.keys(name);
|
||||
|
||||
return this.spectron.client.keys(['NULL', 'Enter', 'NULL']);
|
||||
}
|
||||
|
||||
public async installExtension(name: string): Promise<any> {
|
||||
const extensionListSelector = `${this.extensionsViewletSelector} .monaco-list-rows`;
|
||||
this.viewletExtensionIndex = await this.getExtensionIndex(name, extensionListSelector);
|
||||
|
||||
try {
|
||||
return this.spectron.client.click(`${extensionListSelector}>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.install`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to click on install button for selected extension.');
|
||||
}
|
||||
}
|
||||
|
||||
public getExtensionReloadText(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `${this.extensionsViewletSelector} .monaco-list-rows>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.reload`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Reload was not prompted for an installed extension.');
|
||||
}
|
||||
}
|
||||
|
||||
public async activateExtension(): Promise<any> {
|
||||
await this.common.showCommands();
|
||||
await this.common.type('Smoke Test Check');
|
||||
await this.spectron.wait();
|
||||
return this.common.enter();
|
||||
}
|
||||
|
||||
public verifyStatusbarItem(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, '.statusbar-item.statusbar-entry span[title="smoke test"]');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to validate extension contribution.');
|
||||
}
|
||||
}
|
||||
|
||||
private getExtensionIndex(name: string, extensionListSelector: string): Promise<number> {
|
||||
return this.spectron.waitFor(this.spectron.client.getHTML, extensionListSelector).then(html => {
|
||||
return new Promise<number>((res, rej) => {
|
||||
let extensionIndex: number = 0;
|
||||
let extension: boolean;
|
||||
let tags: string[] = [];
|
||||
let parser = new htmlparser.Parser({
|
||||
onopentag: function (name, attribs) {
|
||||
if (name === 'div' && attribs.class === 'extension') {
|
||||
extensionIndex++;
|
||||
extension = true;
|
||||
}
|
||||
if (extension) {
|
||||
tags.push(name);
|
||||
}
|
||||
},
|
||||
ontext: function (text) {
|
||||
if (extension && text === name) {
|
||||
parser.end();
|
||||
}
|
||||
},
|
||||
onclosetag: function (name) {
|
||||
if (extension) {
|
||||
tags.pop();
|
||||
}
|
||||
if (extension && tags.length === 0) {
|
||||
extension = false;
|
||||
}
|
||||
},
|
||||
onend: function () {
|
||||
if (extensionIndex === 0) {
|
||||
return rej(`${name} extension was not found.`);
|
||||
}
|
||||
return res(extensionIndex);
|
||||
}
|
||||
});
|
||||
parser.write(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
21
test/smoke/src/areas/first-experience.ts
Normal file
21
test/smoke/src/areas/first-experience.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export class FirstExperience {
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public async getWelcomeTab(): Promise<any> {
|
||||
let el = await this.spectron.client.element('.vs_code_welcome_page-name-file-icon');
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
167
test/smoke/src/areas/git.ts
Normal file
167
test/smoke/src/areas/git.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
import { CommonActions } from './common';
|
||||
|
||||
var htmlparser = require('htmlparser2');
|
||||
|
||||
export class Git {
|
||||
private editorChangeIndex: number;
|
||||
|
||||
constructor(private spectron: SpectronApplication, private commonActions: CommonActions) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public openGitViewlet(): Promise<any> {
|
||||
return this.spectron.command('workbench.view.scm');
|
||||
}
|
||||
|
||||
public getScmIconChanges(): Promise<any> {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, 'div[id="workbench.parts.activitybar"] .badge.scm-viewlet-label .badge-content');
|
||||
}
|
||||
|
||||
public async verifyScmChange(fileName: string): Promise<any> {
|
||||
let el;
|
||||
try {
|
||||
el = await this.spectron.client.element(`div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.commonActions.getExtensionSelector(fileName)}"]`);
|
||||
} catch (e) {
|
||||
return Promise.reject(`${fileName} change is not present in SCM viewlet.`);
|
||||
}
|
||||
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async getOriginalAppJsBodyVarName(): Promise<any> {
|
||||
this.editorChangeIndex = await this.getFirstChangeIndex('cdr line-delete', '.editor.original .view-overlays');
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `.editor.original .view-lines>:nth-child(${this.editorChangeIndex}) .mtk11`);
|
||||
}
|
||||
|
||||
public getModifiedAppJsBodyVarName(): Promise<any> {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `.editor.modified .view-lines>:nth-child(${this.editorChangeIndex}) .mtk11`);
|
||||
}
|
||||
|
||||
public async stageFile(fileName: string): Promise<any> {
|
||||
try {
|
||||
await this.spectron.client.moveToObject(`div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.commonActions.getExtensionSelector(fileName)}"`);
|
||||
} catch (e) {
|
||||
return Promise.reject(`${fileName} was not found in SCM viewlet`);
|
||||
}
|
||||
|
||||
await this.spectron.wait();
|
||||
|
||||
try {
|
||||
await this.spectron.client.click('.action-label.icon.contrib-cmd-icon-4');
|
||||
} catch (e) {
|
||||
return Promise.reject('Stage button was not found');
|
||||
}
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public async unstageFile(fileName: string): Promise<any> {
|
||||
try {
|
||||
await this.spectron.client.moveToObject(`div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.commonActions.getExtensionSelector(fileName)}"`);
|
||||
} catch (e) {
|
||||
return Promise.reject(`${fileName} was not found in SCM viewlet`);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.spectron.client.click('.action-label.icon.contrib-cmd-icon-6');
|
||||
} catch (e) {
|
||||
return Promise.reject('Unstage button was not found.');
|
||||
}
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public async getStagedCount(): Promise<any> {
|
||||
let scmHeaders: Array<string>;
|
||||
try {
|
||||
scmHeaders = await this.spectron.waitFor(this.spectron.client.getText, '.scm-status.show-file-icons .monaco-list-rows .name'); // get all headers
|
||||
}
|
||||
catch (e) {
|
||||
return Promise.reject('No row names in SCM viewlet were found.');
|
||||
}
|
||||
|
||||
const stagedTitle = scmHeaders.find((val) => {
|
||||
return val.match(/staged/i) ? true : false;
|
||||
});
|
||||
|
||||
if (!stagedTitle) {
|
||||
return Promise.reject(`No 'Staged' header title found in SCM viewlet`);
|
||||
}
|
||||
|
||||
const monacoRowIndex = scmHeaders.indexOf(stagedTitle);
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `.scm-status.show-file-icons .monaco-list-rows>:nth-child(${monacoRowIndex + 1}) .monaco-count-badge`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Stage count badge cannot be found');
|
||||
}
|
||||
}
|
||||
|
||||
public focusOnCommitBox(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.client.click('div[id="workbench.view.scm"] textarea');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to focus on commit box: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public async pressCommit(): Promise<any> {
|
||||
try {
|
||||
await this.spectron.client.click('.action-label.icon.contrib-cmd-icon-10');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to press commit: ' + e);
|
||||
}
|
||||
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public getOutgoingChanges(): Promise<string> {
|
||||
try {
|
||||
return this.spectron.client.getText('a[title="Synchronize Changes"]');
|
||||
} catch (e) {
|
||||
return Promise.reject(`Failed to obtain 'synchronize changes' title value from the status bar.`);
|
||||
}
|
||||
}
|
||||
|
||||
private getFirstChangeIndex(changeClass: string, selector: string): Promise<number> {
|
||||
return this.spectron.waitFor(this.spectron.client.getHTML, selector).then(html => {
|
||||
return new Promise<number>((res, rej) => {
|
||||
let lineIndex: number = 0;
|
||||
let changeFound: boolean;
|
||||
let tags: string[] = [];
|
||||
let parser = new htmlparser.Parser({
|
||||
onopentag: function (name: string, attribs: any) {
|
||||
tags.push(name);
|
||||
if (name === 'div' && !attribs.class) {
|
||||
lineIndex++;
|
||||
} else if (name === 'div' && attribs.class === changeClass) {
|
||||
changeFound = true;
|
||||
parser.end();
|
||||
}
|
||||
},
|
||||
onclosetag: function (name) {
|
||||
// Terminate once last tag is closed
|
||||
tags.pop();
|
||||
if (!changeFound && tags.length === 0) {
|
||||
parser.end();
|
||||
}
|
||||
},
|
||||
onend: function () {
|
||||
if (!changeFound) {
|
||||
return rej(`No changes in the diff found.`);
|
||||
}
|
||||
return res(lineIndex);
|
||||
}
|
||||
});
|
||||
parser.write(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
54
test/smoke/src/areas/integrated-terminal.ts
Normal file
54
test/smoke/src/areas/integrated-terminal.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
import { CommonActions } from './common';
|
||||
|
||||
export class IntegratedTerminal {
|
||||
|
||||
public static terminalSelector = 'div[id="workbench.panel.terminal"]';
|
||||
public static terminalRowsSelector = 'div[id="workbench.panel.terminal"] .xterm-rows';
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public async openTerminal(commonActions: CommonActions): Promise<any> {
|
||||
// Backquote dispatching does not work in OS X
|
||||
if (process.platform === 'darwin') {
|
||||
await commonActions.showCommands();
|
||||
await commonActions.type('Toggle Integrated Terminal');
|
||||
return commonActions.enter();
|
||||
}
|
||||
|
||||
await this.spectron.command('workbench.action.terminal.toggleTerminal');
|
||||
|
||||
// If no terminal panel was opened, try triggering terminal from quick open
|
||||
try {
|
||||
await this.spectron.client.getHTML(IntegratedTerminal.terminalSelector);
|
||||
} catch (e) {
|
||||
await commonActions.openQuickOpen();
|
||||
await this.spectron.client.keys('>Toggle Integrated Terminal');
|
||||
await this.spectron.client.keys(['Enter', 'NULL']);
|
||||
}
|
||||
}
|
||||
|
||||
public async commandOutputHas(result: string): Promise<boolean> {
|
||||
const rows = await this.spectron.client.elements(`${IntegratedTerminal.terminalRowsSelector} div`);
|
||||
for (let i = 0; i < rows.value.length; i++) {
|
||||
let rowText;
|
||||
try {
|
||||
rowText = await this.spectron.client.getText(`${IntegratedTerminal.terminalRowsSelector}>:nth-child(${i + 1})`);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Failed to obtain text from line ${i + 1} from the terminal.`);
|
||||
}
|
||||
if (rowText.trim() === result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
53
test/smoke/src/areas/javascript-debug.ts
Normal file
53
test/smoke/src/areas/javascript-debug.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
var stripJsonComments = require('strip-json-comments');
|
||||
|
||||
export class JavaScriptDebug {
|
||||
private readonly sidebarSelector = '.margin-view-overlays';
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public openDebugViewlet(): Promise<any> {
|
||||
return this.spectron.command('workbench.view.debug');
|
||||
}
|
||||
|
||||
public async pressConfigureLaunchJson(): Promise<any> {
|
||||
try {
|
||||
await this.spectron.waitFor(this.spectron.client.click, 'ul[aria-label="Debug actions"] .action-label.icon.debug-action.configure');
|
||||
} catch (e) {
|
||||
return Promise.reject('Clicking on debug configuration gear failed.');
|
||||
}
|
||||
await this.spectron.wait();
|
||||
await this.spectron.client.keys(['ArrowDown', 'NULL', 'Enter']);
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public async getProgramConfigValue(): Promise<any> {
|
||||
const lines = stripJsonComments(await this.spectron.client.getText('.view-lines'));
|
||||
const json = JSON.parse(lines);
|
||||
return json.configurations[0].program;
|
||||
}
|
||||
|
||||
public setBreakpointOnLine(lineNumber: number): Promise<any> {
|
||||
try {
|
||||
return this.spectron.client.leftClick(`${this.sidebarSelector}>:nth-child(${lineNumber})`, 5, 5);
|
||||
} catch (e) {
|
||||
return Promise.reject('Setting breakpoint failed: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public async verifyBreakpointOnLine(lineNumber: number): Promise<any> {
|
||||
let el = await this.spectron.client.element(`${this.sidebarSelector}>:nth-child(${lineNumber}) .cgmr.debug-breakpoint-glyph`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
186
test/smoke/src/areas/javascript.ts
Normal file
186
test/smoke/src/areas/javascript.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
var htmlparser = require('htmlparser2');
|
||||
|
||||
export class JavaScript {
|
||||
private appVarSelector: string;
|
||||
private expressVarSelector: string;
|
||||
|
||||
private foldSelector: string;
|
||||
private foldLine: number;
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public openQuickOutline(): Promise<any> {
|
||||
return this.spectron.command('workbench.action.gotoSymbol');
|
||||
}
|
||||
|
||||
public async findAppReferences(): Promise<any> {
|
||||
await this.setAppVarSelector();
|
||||
try {
|
||||
await this.spectron.client.click(this.appVarSelector, false);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Failed to select 'app' variable.`);
|
||||
}
|
||||
|
||||
return this.spectron.command('editor.action.referenceSearch.trigger');
|
||||
}
|
||||
|
||||
public async getTitleReferencesCount(): Promise<any> {
|
||||
const meta = await this.spectron.client.getText('.reference-zone-widget.results-loaded .peekview-title .meta');
|
||||
|
||||
return meta.match(/\d+/)[0];
|
||||
}
|
||||
|
||||
public async getTreeReferencesCount(): Promise<any> {
|
||||
const treeElems = await this.spectron.client.elements('.reference-zone-widget.results-loaded .ref-tree.inline .show-twisties .monaco-tree-row');
|
||||
|
||||
return treeElems.value.length;
|
||||
}
|
||||
|
||||
public async renameApp(newValue: string): Promise<any> {
|
||||
await this.setAppVarSelector();
|
||||
|
||||
try {
|
||||
await this.spectron.client.click(this.appVarSelector);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Failed to select 'app' variable.`);
|
||||
}
|
||||
await this.spectron.command('editor.action.rename');
|
||||
await this.spectron.wait();
|
||||
return this.spectron.client.keys(newValue, false);
|
||||
}
|
||||
|
||||
public async getNewAppName(): Promise<any> {
|
||||
return this.spectron.client.getText(this.appVarSelector);
|
||||
}
|
||||
|
||||
public async toggleFirstCommentFold(): Promise<any> {
|
||||
this.foldLine = await this.getLineIndexOfFirstFoldableElement(`.margin-view-overlays`);
|
||||
this.foldSelector = `.margin-view-overlays>:nth-child(${this.foldLine})`;
|
||||
|
||||
try {
|
||||
return this.spectron.client.click(`${this.foldSelector} .cldr.folding`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Clicking on fold element failed ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public async getFirstCommentFoldedIcon(): Promise<any> {
|
||||
if (!this.foldSelector) {
|
||||
return Promise.reject('No code folding happened to be able to check for a folded icon.');
|
||||
}
|
||||
|
||||
return this.spectron.client.getHTML(`${this.foldSelector} .cldr.folding.collapsed`);
|
||||
}
|
||||
|
||||
public async getNextLineNumberAfterFold(): Promise<any> {
|
||||
if (!this.foldLine) {
|
||||
return Promise.reject('Folded line was not set, most likely because fold was not toggled initially.');
|
||||
}
|
||||
|
||||
return this.spectron.client.getText(`.margin-view-overlays>:nth-child(${this.foldLine + 1}) .line-numbers`);
|
||||
}
|
||||
|
||||
public async goToExpressDefinition(): Promise<any> {
|
||||
await this.setExpressVarSelector();
|
||||
try {
|
||||
await this.spectron.client.click(this.expressVarSelector);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Clicking on express variable failed: ` + e);
|
||||
}
|
||||
|
||||
return this.spectron.command('editor.action.goToDeclaration');
|
||||
}
|
||||
|
||||
public async peekExpressDefinition(): Promise<any> {
|
||||
await this.setExpressVarSelector();
|
||||
try {
|
||||
await this.spectron.client.click(this.expressVarSelector);
|
||||
} catch (e) {
|
||||
return Promise.reject('Clicking on express variable failed: ' + e);
|
||||
}
|
||||
|
||||
return this.spectron.command('editor.action.previewDeclaration');
|
||||
}
|
||||
|
||||
public async getPeekExpressResultName(): Promise<any> {
|
||||
return this.spectron.client.getText('.reference-zone-widget.results-loaded .filename');
|
||||
}
|
||||
|
||||
private async setAppVarSelector(): Promise<any> {
|
||||
if (!this.appVarSelector) {
|
||||
const lineIndex = await this.getLineIndexOfFirst('app', '.view-lines');
|
||||
this.appVarSelector = `.view-lines>:nth-child(${lineIndex}) .mtk11`;
|
||||
}
|
||||
}
|
||||
|
||||
private async setExpressVarSelector(): Promise<any> {
|
||||
if (!this.expressVarSelector) {
|
||||
const lineIndex = await this.getLineIndexOfFirst('express', '.view-lines');
|
||||
this.expressVarSelector = `.view-lines>:nth-child(${lineIndex}) .mtk10`;
|
||||
}
|
||||
}
|
||||
|
||||
private getLineIndexOfFirst(string: string, selector: string): Promise<number> {
|
||||
return this.spectron.waitFor(this.spectron.client.getHTML, selector).then(html => {
|
||||
return new Promise<number>((res, rej) => {
|
||||
let lineIndex: number = 0;
|
||||
let stringFound: boolean;
|
||||
let parser = new htmlparser.Parser({
|
||||
onopentag: function (name: string, attribs: any) {
|
||||
if (name === 'div' && attribs.class === 'view-line') {
|
||||
lineIndex++;
|
||||
}
|
||||
},
|
||||
ontext: function (text) {
|
||||
if (!stringFound && text === string) {
|
||||
stringFound = true;
|
||||
parser.end();
|
||||
}
|
||||
},
|
||||
onend: function () {
|
||||
if (!stringFound) {
|
||||
return rej(`No ${string} in editor found.`);
|
||||
}
|
||||
return res(lineIndex);
|
||||
}
|
||||
});
|
||||
parser.write(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private getLineIndexOfFirstFoldableElement(selector: string): Promise<number> {
|
||||
return this.spectron.waitFor(this.spectron.client.getHTML, selector).then(html => {
|
||||
return new Promise<number>((res, rej) => {
|
||||
let lineIndex: number = 0;
|
||||
let foldFound: boolean;
|
||||
let parser = new htmlparser.Parser({
|
||||
onopentag: function (name: string, attribs: any) {
|
||||
if (name === 'div' && !attribs.class) {
|
||||
lineIndex++;
|
||||
} else if (name === 'div' && attribs.class.indexOf('cldr folding') !== -1) {
|
||||
foldFound = true;
|
||||
parser.end();
|
||||
}
|
||||
},
|
||||
onend: function () {
|
||||
if (!foldFound) {
|
||||
return rej(`No foldable elements found.`);
|
||||
}
|
||||
return res(lineIndex);
|
||||
}
|
||||
});
|
||||
parser.write(html);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
70
test/smoke/src/areas/localization.ts
Normal file
70
test/smoke/src/areas/localization.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export enum ViewletType {
|
||||
SEARCH = 0,
|
||||
SCM = 1,
|
||||
DEBUG = 2,
|
||||
EXTENSIONS = 3
|
||||
}
|
||||
|
||||
export class Localization {
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public async getOpenEditorsText(): Promise<string> {
|
||||
let explorerTitles;
|
||||
try {
|
||||
explorerTitles = await this.spectron.client.getText('div[id="workbench.view.explorer"] .title span');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to get span of title in explorer viewlet.');
|
||||
}
|
||||
|
||||
return explorerTitles[0];
|
||||
}
|
||||
|
||||
public async openViewlet(type: ViewletType): Promise<any> {
|
||||
let command;
|
||||
|
||||
switch (type) {
|
||||
case ViewletType.SEARCH:
|
||||
command = 'workbench.view.search';
|
||||
break;
|
||||
case ViewletType.SCM:
|
||||
command = 'workbench.view.scm';
|
||||
break;
|
||||
case ViewletType.DEBUG:
|
||||
command = 'workbench.view.debug';
|
||||
break;
|
||||
case ViewletType.EXTENSIONS:
|
||||
command = 'workbench.view.extensions';
|
||||
break;
|
||||
}
|
||||
|
||||
await this.spectron.command(command, false);
|
||||
return this.spectron.wait();
|
||||
}
|
||||
|
||||
public getOpenedViewletTitle(): Promise<string> {
|
||||
try {
|
||||
return this.spectron.client.getText('div[id="workbench.parts.sidebar"] .title-label span');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to get span of title label in explorer viewlet.');
|
||||
}
|
||||
}
|
||||
|
||||
public getExtensionsSearchPlaceholder(): Promise<string> {
|
||||
try {
|
||||
return this.spectron.client.getAttribute('div[id="workbench.view.extensions"] .search-box', 'placeholder');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to get extension viewlet search box placeholder.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
74
test/smoke/src/areas/search.ts
Normal file
74
test/smoke/src/areas/search.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export class Search {
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public openSearchViewlet(): Promise<any> {
|
||||
return this.spectron.command('workbench.view.search');
|
||||
}
|
||||
|
||||
public async searchFor(text: string): Promise<any> {
|
||||
await this.spectron.client.keys(text);
|
||||
return this.spectron.client.keys(['NULL', 'Enter', 'NULL'], false);
|
||||
}
|
||||
|
||||
public setReplaceText(text: string): any {
|
||||
try {
|
||||
return this.spectron.client.setValue('.viewlet .input[title="Replace"]', text);
|
||||
} catch (e) {
|
||||
return Promise.reject('Cannot set replace input in the viewlet: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public replaceFirstMatch(): any {
|
||||
try {
|
||||
return this.spectron.client.click('.monaco-tree-rows.show-twisties .action-label.icon.action-replace-all');
|
||||
} catch (e) {
|
||||
return Promise.reject('Cannot replace the search first match: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultText(): any {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, '.search-viewlet .message>p');
|
||||
}
|
||||
|
||||
public toggleSearchDetails(): any {
|
||||
try {
|
||||
return this.spectron.client.click('.query-details .more');
|
||||
} catch (e) {
|
||||
return Promise.reject('Toggling search details failed: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public toggleReplace(): any {
|
||||
try {
|
||||
return this.spectron.client.click('.monaco-button.toggle-replace-button.collapse');
|
||||
} catch (e) {
|
||||
return Promise.reject('Toggling replace failed: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public hoverOverResultCount(): any {
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.moveToObject, '.monaco-count-badge');
|
||||
} catch (e) {
|
||||
return Promise.reject('Hovering over result count failed: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public dismissResult(): any {
|
||||
try {
|
||||
return this.spectron.client.click('.action-label.icon.action-remove');
|
||||
} catch (e) {
|
||||
return Promise.reject('Clicking on dismissing result failed: ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
103
test/smoke/src/areas/statusbar.ts
Normal file
103
test/smoke/src/areas/statusbar.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
|
||||
export enum StatusBarElement {
|
||||
BRANCH_STATUS = 0,
|
||||
SYNC_STATUS = 1,
|
||||
PROBLEMS_STATUS = 2,
|
||||
SELECTION_STATUS = 3,
|
||||
INDENTATION_STATUS = 4,
|
||||
ENCODING_STATUS = 5,
|
||||
EOL_STATUS = 6,
|
||||
LANGUAGE_STATUS = 7,
|
||||
FEEDBACK_ICON = 8
|
||||
}
|
||||
|
||||
export class StatusBar {
|
||||
|
||||
private selectorsMap: Map<StatusBarElement, string>;
|
||||
private readonly mainSelector = 'div[id="workbench.parts.statusbar"]';
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
this.populateSelectorsMap();
|
||||
}
|
||||
|
||||
public async isVisible(element: StatusBarElement): Promise<boolean> {
|
||||
const selector = this.selectorsMap.get(element);
|
||||
if (!selector) {
|
||||
throw new Error('No such element in the status bar defined.');
|
||||
}
|
||||
|
||||
return this.spectron.client.isVisible(selector);
|
||||
}
|
||||
|
||||
public async clickOn(element: StatusBarElement): Promise<any> {
|
||||
const selector = this.selectorsMap.get(element);
|
||||
if (!selector) {
|
||||
throw new Error('No such element in the status bar defined.');
|
||||
}
|
||||
|
||||
try {
|
||||
return this.spectron.client.click(selector);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Clicking on status bar element ${selector} failed.`);
|
||||
}
|
||||
}
|
||||
|
||||
public async getProblemsView(): Promise<any> {
|
||||
let el = await this.spectron.client.element('div[id="workbench.panel.markers"]');
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async getFeedbackView(): Promise<any> {
|
||||
let el = await this.spectron.client.element('.feedback-form');
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public isQuickOpenWidgetVisible(): Promise<any> {
|
||||
return this.spectron.client.isVisible('.quick-open-widget');
|
||||
}
|
||||
|
||||
public async getEditorHighlightedLine(lineNumber: number): Promise<any> {
|
||||
let el = await this.spectron.client.element(`.monaco-editor .view-overlays>:nth-child(${lineNumber}) .current-line`);
|
||||
if (el.status === 0) {
|
||||
return el;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async getEOLMode(): Promise<any> {
|
||||
const selector = this.selectorsMap.get(StatusBarElement.EOL_STATUS);
|
||||
if (!selector) {
|
||||
throw new Error('No such element in the status bar defined.');
|
||||
}
|
||||
|
||||
return this.spectron.client.getText(selector);
|
||||
}
|
||||
|
||||
private populateSelectorsMap(): void {
|
||||
this.selectorsMap = new Map<StatusBarElement, string>();
|
||||
this.selectorsMap.set(StatusBarElement.BRANCH_STATUS, `${this.mainSelector} .octicon.octicon-git-branch`);
|
||||
this.selectorsMap.set(StatusBarElement.SYNC_STATUS, `${this.mainSelector} .octicon.octicon-sync`);
|
||||
this.selectorsMap.set(StatusBarElement.PROBLEMS_STATUS, `${this.mainSelector} .task-statusbar-item[title="Problems"]`);
|
||||
this.selectorsMap.set(StatusBarElement.SELECTION_STATUS, `${this.mainSelector} .editor-status-selection`);
|
||||
this.selectorsMap.set(StatusBarElement.INDENTATION_STATUS, `${this.mainSelector} .editor-status-indentation`);
|
||||
this.selectorsMap.set(StatusBarElement.ENCODING_STATUS, `${this.mainSelector} .editor-status-encoding`);
|
||||
this.selectorsMap.set(StatusBarElement.EOL_STATUS, `${this.mainSelector} .editor-status-eol`);
|
||||
this.selectorsMap.set(StatusBarElement.LANGUAGE_STATUS, `${this.mainSelector} .editor-status-mode`);
|
||||
this.selectorsMap.set(StatusBarElement.FEEDBACK_ICON, `${this.mainSelector} .dropdown.send-feedback`);
|
||||
}
|
||||
}
|
||||
89
test/smoke/src/areas/tasks.ts
Normal file
89
test/smoke/src/areas/tasks.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SpectronApplication } from '../spectron/application';
|
||||
import { IntegratedTerminal } from './integrated-terminal';
|
||||
|
||||
export class Tasks {
|
||||
|
||||
private readonly outputViewSelector = IntegratedTerminal.terminalRowsSelector;
|
||||
private readonly workbenchPanelSelector = 'div[id="workbench.parts.panel"]';
|
||||
private readonly problemsViewSelector = 'div[id="workbench.panel.markers"] .monaco-tree-row.expanded';
|
||||
|
||||
constructor(private spectron: SpectronApplication) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public async build(): Promise<any> {
|
||||
await this.spectron.command('workbench.action.tasks.build');
|
||||
await this.spectron.wait(); // wait for build to finish
|
||||
|
||||
// Validate that it has finished
|
||||
let trial = 0;
|
||||
while (trial < 3) {
|
||||
// Determine build status based on the statusbar indicator, don't continue until task has been terminated
|
||||
try {
|
||||
return await this.spectron.client.getValue('.task-statusbar-item-progress.builder-hidden');
|
||||
} catch (e) {
|
||||
await this.spectron.wait();
|
||||
trial++;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject('Could not determine if the task was terminated based on status bar progress spinner.');
|
||||
}
|
||||
|
||||
public openProblemsView(): Promise<any> {
|
||||
return this.spectron.command('workbench.actions.view.problems');
|
||||
}
|
||||
|
||||
public async outputContains(string: string): Promise<boolean> {
|
||||
const output: string = await this.spectron.waitFor(this.spectron.client.getText, this.outputViewSelector);
|
||||
|
||||
if (output.indexOf(string) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async selectOutputViewType(type: string): Promise<any> {
|
||||
await this.openOutputView();
|
||||
|
||||
try {
|
||||
return this.spectron.client.selectByValue(`${this.workbenchPanelSelector} .select-box`, type);
|
||||
} catch (e) {
|
||||
return Promise.reject(`Failed to select ${type} as workbench panel output.`);
|
||||
}
|
||||
}
|
||||
|
||||
public getOutputViewType(): Promise<any> {
|
||||
return this.spectron.client.getValue(`${this.workbenchPanelSelector} .select-box`);
|
||||
}
|
||||
|
||||
public getProblemsViewFirstElementName(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `${this.problemsViewSelector} .label-name`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to get problem label from Problems view: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
public getProblemsViewFirstElementCount(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.waitFor(this.spectron.client.getText, `${this.problemsViewSelector} .monaco-count-badge`);
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to get problem count from Problems view: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
private openOutputView(): Promise<any> {
|
||||
try {
|
||||
return this.spectron.command('workbench.action.output.toggleOutput');
|
||||
} catch (e) {
|
||||
return Promise.reject('Failed to toggle output view');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user