Merge pull request #148918 from microsoft/tyriar/146700_2

Fix, re-enable or disable skipped terminal smoke tests
This commit is contained in:
Daniel Imms
2022-05-06 12:14:15 -07:00
committed by GitHub
16 changed files with 117 additions and 86 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ export class Application {
extraArgs: [...(this.options.extraArgs || []), ...extraArgs],
});
this._workbench = new Workbench(this._code, this.userDataPath);
this._workbench = new Workbench(this._code);
return code;
}
+6 -7
View File
@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as path from 'path';
import { Editor } from './editor';
import { Editors } from './editors';
import { Code } from './code';
@@ -12,7 +10,7 @@ import { QuickAccess } from './quickaccess';
export class SettingsEditor {
constructor(private code: Code, private userDataPath: string, private editors: Editors, private editor: Editor, private quickaccess: QuickAccess) { }
constructor(private code: Code, private editors: Editors, private editor: Editor, private quickaccess: QuickAccess) { }
async addUserSetting(setting: string, value: string): Promise<void> {
await this.openUserSettingsFile();
@@ -23,11 +21,12 @@ export class SettingsEditor {
}
async clearUserSettings(): Promise<void> {
const settingsPath = path.join(this.userDataPath, 'User', 'settings.json');
await new Promise<void>((c, e) => fs.writeFile(settingsPath, '{\n}', 'utf8', err => err ? e(err) : c()));
await this.openUserSettingsFile();
await this.editor.waitForEditorContents('settings.json', c => c === '{}');
await this.quickaccess.runCommand('editor.action.selectAll');
await this.code.dispatchKeybinding('Delete');
await this.editor.waitForTypeInEditor('settings.json', `{`); // will auto close }
await this.editors.saveOpenedFile();
await this.quickaccess.runCommand('workbench.action.closeActiveEditor');
}
async openUserSettingsFile(): Promise<void> {
+12 -11
View File
@@ -6,6 +6,7 @@
import { QuickInput } from './quickinput';
import { Code } from './code';
import { QuickAccess } from './quickaccess';
import { IElement } from './driver';
export enum Selector {
TerminalView = `#terminal`,
@@ -75,7 +76,7 @@ export class Terminal {
constructor(private code: Code, private quickaccess: QuickAccess, private quickinput: QuickInput) { }
async runCommand(commandId: TerminalCommandId): Promise<void> {
async runCommand(commandId: TerminalCommandId, expectedLocation?: 'editor' | 'panel'): Promise<void> {
const keepOpen = commandId === TerminalCommandId.Join;
await this.quickaccess.runCommand(commandId, keepOpen);
if (keepOpen) {
@@ -83,7 +84,7 @@ export class Terminal {
await this.quickinput.waitForQuickInputClosed();
}
if (commandId === TerminalCommandId.Show || commandId === TerminalCommandId.CreateNewEditor || commandId === TerminalCommandId.CreateNew || commandId === TerminalCommandId.NewWithProfile) {
return await this._waitForTerminal(commandId === TerminalCommandId.CreateNewEditor ? 'editor' : 'panel');
return await this._waitForTerminal(expectedLocation === 'editor' || commandId === TerminalCommandId.CreateNewEditor ? 'editor' : 'panel');
}
}
@@ -114,11 +115,11 @@ export class Terminal {
/**
* Creates a terminal using the new terminal command.
* @param location The location to check the terminal for, defaults to panel.
* @param expectedLocation The location to check the terminal for, defaults to panel.
*/
async createTerminal(location?: 'editor' | 'panel'): Promise<void> {
await this.runCommand(TerminalCommandId.CreateNew);
await this._waitForTerminal(location);
async createTerminal(expectedLocation?: 'editor' | 'panel'): Promise<void> {
await this.runCommand(TerminalCommandId.CreateNew, expectedLocation);
await this._waitForTerminal(expectedLocation);
}
async assertEditorGroupCount(count: number): Promise<void> {
@@ -160,11 +161,11 @@ export class Terminal {
const groups: TerminalGroup[] = [];
for (let i = 0; i < tabCount; i++) {
const title = await this.code.waitForElement(`${Selector.Tabs}[data-index="${i}"] ${Selector.TabsEntry}`, e => e?.textContent?.length ? e?.textContent?.length > 1 : false);
const description = await this.code.waitForElement(`${Selector.Tabs}[data-index="${i}"] ${Selector.TabsEntry} ${Selector.Description}`, e => e?.textContent?.length ? e?.textContent?.length > 1 : false);
const description: IElement | undefined = await this.code.waitForElement(`${Selector.Tabs}[data-index="${i}"] ${Selector.TabsEntry} ${Selector.Description}`, () => true);
const label: TerminalLabel = {
name: title.textContent.replace(/^[├┌└]\s*/, ''),
description: description.textContent
description: description?.textContent
};
// It's a new group if the the tab does not start with ├ or └
if (title.textContent.match(/^[├└]/)) {
@@ -257,10 +258,10 @@ export class Terminal {
/**
* Waits for the terminal to be focused and to contain content.
* @param location The location to check the terminal for, defaults to panel.
* @param expectedLocation The location to check the terminal for, defaults to panel.
*/
private async _waitForTerminal(location?: 'editor' | 'panel'): Promise<void> {
private async _waitForTerminal(expectedLocation?: 'editor' | 'panel'): Promise<void> {
await this.code.waitForElement(Selector.XtermFocused);
await this.code.waitForTerminalBuffer(location === 'editor' ? Selector.XtermEditor : Selector.Xterm, lines => lines.some(line => line.length > 0));
await this.code.waitForTerminalBuffer(expectedLocation === 'editor' ? Selector.XtermEditor : Selector.Xterm, lines => lines.some(line => line.length > 0));
}
}
+2 -2
View File
@@ -46,7 +46,7 @@ export class Workbench {
readonly notebook: Notebook;
readonly localization: Localization;
constructor(code: Code, userDataPath: string) {
constructor(code: Code) {
this.editors = new Editors(code);
this.quickinput = new QuickInput(code);
this.quickaccess = new QuickAccess(code, this.editors, this.quickinput);
@@ -59,7 +59,7 @@ export class Workbench {
this.debug = new Debug(code, this.quickaccess, this.editors, this.editor);
this.statusbar = new StatusBar(code);
this.problems = new Problems(code, this.quickaccess);
this.settingsEditor = new SettingsEditor(code, userDataPath, this.editors, this.editor, this.quickaccess);
this.settingsEditor = new SettingsEditor(code, this.editors, this.editor, this.quickaccess);
this.keybindingsEditor = new KeybindingsEditor(code);
this.terminal = new Terminal(code, this.quickaccess, this.quickinput);
this.notebook = new Notebook(this.quickaccess, code);