提交 550e32ea 编写于 作者: S Sandeep Somavarapu

Smoke test: Fix terminal tests

上级 ee9d0246
......@@ -16,11 +16,9 @@ describe('Terminal', () => {
const expected = new Date().getTime().toString();
await app.workbench.terminal.showTerminal();
const currentLine = await app.workbench.terminal.getCurrentLineNumber();
await app.workbench.terminal.runCommand(`echo ${expected}`);
const resultLineNumber = await app.workbench.terminal.runCommand(`echo ${expected}`);
const actual = await app.workbench.terminal.waitForTextInLine(currentLine + 1, text => !!text.trim());
app.screenshot.capture('Terminal text');
const actual = await app.workbench.terminal.waitForTextInLine(resultLineNumber, text => text.trim() === expected);
assert.equal(actual.trim(), expected);
});
});
\ No newline at end of file
......@@ -17,7 +17,7 @@ export class Terminal {
if (!await this.isVisible()) {
await this.spectron.workbench.commandPallette.runCommand('Toggle Integrated Terminal');
await this.spectron.client.waitForElement(Terminal.TERMINAL_SELECTOR);
await this.waitForText(text => !!text[text.length - 1] && text[text.length - 1].trim().indexOf('vscode-smoketest-express') !== -1);
await this.waitForTerminalText(text => !!text[text.length - 1] && text[text.length - 1].trim().indexOf('vscode-smoketest-express') !== -1);
}
}
......@@ -26,17 +26,19 @@ export class Terminal {
return !!element;
}
public async runCommand(commandText: string): Promise<void> {
public async runCommand(commandText: string): Promise<number> {
await this.spectron.client.type(commandText);
const currentLineNumber = await this.getCurrentLineNumber();
await this.spectron.client.keys(['Enter', 'NULL']);
return currentLineNumber + 1;
}
public async waitForTextInLine(line: number, fn: (text: string) => boolean): Promise<string> {
const text = await this.waitForText(text => !!text[line]);
return text[line];
const terminalText = await this.waitForTerminalText(terminalText => fn(terminalText[line - 1]));
return terminalText[line - 1];
}
public async waitForText(fn: (text: string[]) => boolean): Promise<string[]> {
public async waitForTerminalText(fn: (text: string[]) => boolean): Promise<string[]> {
return this.spectron.client.waitFor(async () => {
const terminalText = await this.getTerminalText();
if (fn(terminalText)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册