提交 ae4da32e 编写于 作者: S Sandeep Somavarapu

smoke test: remove tasks

上级 708d897c
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. 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');
}
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../spectron/application';
import { Tasks } from '../areas/tasks';
let app: SpectronApplication;
export function testTasks() {
describe('Tasks', () => {
let tasks: Tasks;
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
tasks = new Tasks(app);
return await app.start();
});
afterEach(async function () {
return await app.stop();
});
it('verifies that eslint task results in 1 problem', async function () {
const expectedOutput = '1 problem (0 errors, 1 warning)';
await tasks.build();
const actualOutput = await tasks.outputContains(expectedOutput);
assert.ok(actualOutput, `Output does not contain the following string: '${expectedOutput}'`);
});
it(`is able to select 'Git' output`, async function () {
await tasks.build();
await app.wait();
await tasks.selectOutputViewType('Git');
const viewType = await tasks.getOutputViewType();
assert.equal(viewType, 'Git');
});
it('ensures that build task produces no-unused-vars message', async function () {
await tasks.build();
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 () {
await tasks.build();
await tasks.openProblemsView();
const problemName = await tasks.getProblemsViewFirstElementName();
assert.equal(problemName, 'index.js', `'index.js' is not a build error.`);
const problemsCount = await tasks.getProblemsViewFirstElementCount();
assert.equal(problemsCount, '1', `Problem count is different to expected.`);
});
});
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册