mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 12:11:43 +01:00
Smoke test: Fix terminal tests
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user