提交 bbfcefb4 编写于 作者: M Michel Kaporin

Integrate smoketest-express project tasks 2.0 changes.

上级 a93c51ae
...@@ -8,7 +8,8 @@ import { CommonActions } from "./common"; ...@@ -8,7 +8,8 @@ import { CommonActions } from "./common";
export class IntegratedTerminal { export class IntegratedTerminal {
private readonly terminalDiv = 'div[id="workbench.panel.terminal"]'; public static terminalSelector = 'div[id="workbench.panel.terminal"]';
public static terminalRowsSelector = 'div[id="workbench.panel.terminal"] .xterm-rows';
constructor(private spectron: SpectronApplication) { constructor(private spectron: SpectronApplication) {
// noop // noop
...@@ -26,7 +27,7 @@ export class IntegratedTerminal { ...@@ -26,7 +27,7 @@ export class IntegratedTerminal {
// If no terminal panel was opened, try triggering terminal from quick open // If no terminal panel was opened, try triggering terminal from quick open
try { try {
await this.spectron.client.getHTML(this.terminalDiv); await this.spectron.client.getHTML(IntegratedTerminal.terminalSelector);
} catch (e) { } catch (e) {
await commonActions.openQuickOpen(); await commonActions.openQuickOpen();
await this.spectron.client.keys('>Toggle Integrated Terminal'); await this.spectron.client.keys('>Toggle Integrated Terminal');
...@@ -35,13 +36,11 @@ export class IntegratedTerminal { ...@@ -35,13 +36,11 @@ export class IntegratedTerminal {
} }
public async commandOutputHas(result: string): Promise<boolean> { public async commandOutputHas(result: string): Promise<boolean> {
const selector = `${this.terminalDiv} .xterm-rows`; const rows = await this.spectron.client.elements(`${IntegratedTerminal.terminalRowsSelector} div`);
const rows = await this.spectron.client.elements(`${selector} div`);
for (let i = 0; i < rows.value.length; i++) { for (let i = 0; i < rows.value.length; i++) {
let rowText; let rowText;
try { try {
rowText = await this.spectron.client.getText(`${selector}>:nth-child(${i + 1})`); rowText = await this.spectron.client.getText(`${IntegratedTerminal.terminalRowsSelector}>:nth-child(${i + 1})`);
} catch (e) { } catch (e) {
return Promise.reject(`Failed to obtain text from line ${i + 1} from the terminal.`); return Promise.reject(`Failed to obtain text from line ${i + 1} from the terminal.`);
} }
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { SpectronApplication } from '../spectron/application'; import { SpectronApplication } from '../spectron/application';
import { IntegratedTerminal } from "./integrated-terminal";
export class Tasks { export class Tasks {
private readonly outputViewSelector = 'div[id="workbench.panel.output"] .view-lines'; private readonly outputViewSelector = IntegratedTerminal.terminalRowsSelector;
private readonly workbenchPanelSelector = 'div[id="workbench.parts.panel"]'; private readonly workbenchPanelSelector = 'div[id="workbench.parts.panel"]';
private readonly problemsViewSelector = 'div[id="workbench.panel.markers"] .monaco-tree-row.expanded'; private readonly problemsViewSelector = 'div[id="workbench.panel.markers"] .monaco-tree-row.expanded';
...@@ -20,16 +21,18 @@ export class Tasks { ...@@ -20,16 +21,18 @@ export class Tasks {
await this.spectron.wait(); // wait for build to finish await this.spectron.wait(); // wait for build to finish
// Validate that it has finished // Validate that it has finished
let inProgress = true, trial = 0; let trial = 0;
while (inProgress && trial < 3) { while (trial < 3) {
// Determine build status based on the statusbar indicator, don't continue until task has been terminated // Determine build status based on the statusbar indicator, don't continue until task has been terminated
const hidden = !!await this.spectron.client.getAttribute('.task-statusbar-item-progress', 'aria-hidden'); try {
if (hidden) { return await this.spectron.client.getValue('.task-statusbar-item-progress.builder-hidden');
return Promise.resolve(); } catch (e) {
await this.spectron.wait();
trial++;
} }
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> { public openProblemsView(): Promise<any> {
...@@ -46,7 +49,9 @@ export class Tasks { ...@@ -46,7 +49,9 @@ export class Tasks {
return false; return false;
} }
public selectOutputViewType(type: string): Promise<any> { public async selectOutputViewType(type: string): Promise<any> {
await this.openOutputView();
try { try {
return this.spectron.client.selectByValue(`${this.workbenchPanelSelector} .select-box`, type); return this.spectron.client.selectByValue(`${this.workbenchPanelSelector} .select-box`, type);
} catch (e) { } catch (e) {
...@@ -73,4 +78,12 @@ export class Tasks { ...@@ -73,4 +78,12 @@ export class Tasks {
return Promise.reject('Failed to get problem count from Problems view: ' + 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');
}
}
} }
\ No newline at end of file
...@@ -39,9 +39,9 @@ export function testTasks() { ...@@ -39,9 +39,9 @@ export function testTasks() {
assert.equal(viewType, 'Git'); assert.equal(viewType, 'Git');
}); });
it('ensures that build task produces error in index.js', async function () { it('ensures that build task produces no-unused-vars message', async function () {
await tasks.build(); await tasks.build();
assert.ok(await tasks.outputContains('index.js'), `Output does not contain error in index.js`); assert.ok(await tasks.outputContains(`'next' is defined but never used`), `Output does not contain no-unused-vars message`);
}); });
it(`verifies build error is reflected in 'Problems View'`, async function () { it(`verifies build error is reflected in 'Problems View'`, async function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册