fix terminal smoketests

fixes #48396
This commit is contained in:
Joao Moreno
2018-05-02 12:29:39 +02:00
parent 5dc5b4a90e
commit fe49af2cac
6 changed files with 56 additions and 55 deletions

View File

@@ -3,24 +3,24 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// import { Application } from '../../application';
import { Application } from '../../application';
export function setup() {
describe('Terminal', () => {
// it(`opens terminal, runs 'echo' and verifies the output`, async function () {
// const app = this.app as Application;
it(`opens terminal, runs 'echo' and verifies the output`, async function () {
const app = this.app as Application;
// const expected = new Date().getTime().toString();
// await app.workbench.terminal.showTerminal();
// await app.workbench.terminal.runCommand(`echo ${expected}`);
// await app.workbench.terminal.waitForTerminalText(terminalText => {
// for (let index = terminalText.length - 2; index >= 0; index--) {
// if (!!terminalText[index] && terminalText[index].trim() === expected) {
// return true;
// }
// }
// return false;
// });
// });
const expected = new Date().getTime().toString();
await app.workbench.terminal.showTerminal();
await app.workbench.terminal.runCommand(`echo ${expected}`);
await app.workbench.terminal.waitForTerminalText(terminalText => {
for (let index = terminalText.length - 2; index >= 0; index--) {
if (!!terminalText[index] && terminalText[index].trim() === expected) {
return true;
}
}
return false;
});
});
});
}

View File

@@ -21,7 +21,7 @@ export class Terminal {
}
async runCommand(commandText: string): Promise<void> {
await this.code.waitForPaste(XTERM_TEXTAREA, commandText);
await this.code.writeInTerminal(XTERM_SELECTOR, commandText);
await this.code.dispatchKeybinding('enter');
}

View File

@@ -245,11 +245,6 @@ export class Code {
await poll(() => this.driver.setValue(windowId, selector, value), () => true, `set value '${selector}'`);
}
async waitForPaste(selector: string, value: string): Promise<void> {
const windowId = await this.getActiveWindowId();
await poll(() => this.driver.paste(windowId, selector, value), () => true, `paste '${selector}'`);
}
async waitForElements(selector: string, recursive: boolean, accept: (result: IElement[]) => boolean = result => result.length > 0): Promise<IElement[]> {
const windowId = await this.getActiveWindowId();
return await poll(() => this.driver.getElements(windowId, selector, recursive), accept, `get elements '${selector}'`);
@@ -280,6 +275,11 @@ export class Code {
await poll(() => this.driver.getTerminalBuffer(windowId, selector), accept, `get terminal buffer '${selector}'`);
}
async writeInTerminal(selector: string, value: string): Promise<void> {
const windowId = await this.getActiveWindowId();
await poll(() => this.driver.writeInTerminal(windowId, selector, value), () => true, `writeInTerminal '${selector}'`);
}
private async getActiveWindowId(): Promise<number> {
if (typeof this._activeWindowId !== 'number') {
const windows = await this.driver.getWindowIds();