From bbfcefb4876d23c263982358458fa2315aa757cc Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Mon, 3 Jul 2017 09:15:13 +0200 Subject: [PATCH] Integrate smoketest-express project tasks 2.0 changes. --- test/smoke/src/areas/integrated-terminal.ts | 11 ++++---- test/smoke/src/areas/tasks.ts | 31 +++++++++++++++------ test/smoke/src/tests/tasks.ts | 4 +-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/test/smoke/src/areas/integrated-terminal.ts b/test/smoke/src/areas/integrated-terminal.ts index 0df14e9e099..0b3a3cad031 100644 --- a/test/smoke/src/areas/integrated-terminal.ts +++ b/test/smoke/src/areas/integrated-terminal.ts @@ -8,7 +8,8 @@ import { CommonActions } from "./common"; 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) { // noop @@ -26,7 +27,7 @@ export class IntegratedTerminal { // If no terminal panel was opened, try triggering terminal from quick open try { - await this.spectron.client.getHTML(this.terminalDiv); + await this.spectron.client.getHTML(IntegratedTerminal.terminalSelector); } catch (e) { await commonActions.openQuickOpen(); await this.spectron.client.keys('>Toggle Integrated Terminal'); @@ -35,13 +36,11 @@ export class IntegratedTerminal { } public async commandOutputHas(result: string): Promise { - const selector = `${this.terminalDiv} .xterm-rows`; - - const rows = await this.spectron.client.elements(`${selector} div`); + 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(`${selector}>:nth-child(${i + 1})`); + 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.`); } diff --git a/test/smoke/src/areas/tasks.ts b/test/smoke/src/areas/tasks.ts index 089d81575cf..0ca4357b686 100644 --- a/test/smoke/src/areas/tasks.ts +++ b/test/smoke/src/areas/tasks.ts @@ -4,10 +4,11 @@ *--------------------------------------------------------------------------------------------*/ import { SpectronApplication } from '../spectron/application'; +import { IntegratedTerminal } from "./integrated-terminal"; 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 problemsViewSelector = 'div[id="workbench.panel.markers"] .monaco-tree-row.expanded'; @@ -20,16 +21,18 @@ export class Tasks { await this.spectron.wait(); // wait for build to finish // Validate that it has finished - let inProgress = true, trial = 0; - while (inProgress && trial < 3) { + let trial = 0; + while (trial < 3) { // 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'); - if (hidden) { - return Promise.resolve(); + try { + return await this.spectron.client.getValue('.task-statusbar-item-progress.builder-hidden'); + } 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 { @@ -46,7 +49,9 @@ export class Tasks { return false; } - public selectOutputViewType(type: string): Promise { + public async selectOutputViewType(type: string): Promise { + await this.openOutputView(); + try { return this.spectron.client.selectByValue(`${this.workbenchPanelSelector} .select-box`, type); } catch (e) { @@ -73,4 +78,12 @@ export class Tasks { return Promise.reject('Failed to get problem count from Problems view: ' + e); } } + + private openOutputView(): Promise { + 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 diff --git a/test/smoke/src/tests/tasks.ts b/test/smoke/src/tests/tasks.ts index f653d9dd07f..45fc5d794bb 100644 --- a/test/smoke/src/tests/tasks.ts +++ b/test/smoke/src/tests/tasks.ts @@ -39,9 +39,9 @@ export function testTasks() { 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(); - 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 () { -- GitLab