diff --git a/test/automation/src/quickinput.ts b/test/automation/src/quickinput.ts index 367f13ebb8c..70b37ea9e2d 100644 --- a/test/automation/src/quickinput.ts +++ b/test/automation/src/quickinput.ts @@ -9,9 +9,19 @@ export class QuickInput { static QUICK_INPUT = '.quick-input-widget'; static QUICK_INPUT_INPUT = `${QuickInput.QUICK_INPUT} .quick-input-box input`; + static QUICK_INPUT_ROW = `${QuickInput.QUICK_INPUT} .quick-input-list .monaco-list-row`; + static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT_ROW}.focused .monaco-highlighted-label`; + static QUICK_INPUT_ENTRY_LABEL = `${QuickInput.QUICK_INPUT_ROW} .label-name`; + static QUICK_INPUT_ENTRY_LABEL_SPAN = `${QuickInput.QUICK_INPUT_ROW} .monaco-highlighted-label span`; constructor(private code: Code) { } + async submit(text: string): Promise { + await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, text); + await this.code.dispatchKeybinding('enter'); + await this.waitForQuickInputClosed(); + } + async closeQuickInput(): Promise { await this.code.dispatchKeybinding('escape'); await this.waitForQuickInputClosed(); @@ -21,7 +31,11 @@ export class QuickInput { await this.code.waitForActiveElement(QuickInput.QUICK_INPUT_INPUT, retryCount); } - private async waitForQuickInputClosed(): Promise { + async waitForQuickInputElements(accept: (names: string[]) => boolean): Promise { + await this.code.waitForElements(QuickInput.QUICK_INPUT_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent))); + } + + async waitForQuickInputClosed(): Promise { await this.code.waitForElement(QuickInput.QUICK_INPUT, r => !!r && r.attributes.style.indexOf('display: none;') !== -1); } diff --git a/test/automation/src/quickopen.ts b/test/automation/src/quickopen.ts index 4852a79061c..cd07572b42a 100644 --- a/test/automation/src/quickopen.ts +++ b/test/automation/src/quickopen.ts @@ -5,17 +5,11 @@ import { Editors } from './editors'; import { Code } from './code'; +import { QuickInput } from './quickinput'; export class QuickOpen { - static QUICK_OPEN = '.quick-input-widget'; - static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-input-box input`; - static QUICK_OPEN_ROW = `${QuickOpen.QUICK_OPEN} .quick-input-list .monaco-list-row`; - static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN_ROW}.focused .monaco-highlighted-label`; - static QUICK_OPEN_ENTRY_LABEL = `${QuickOpen.QUICK_OPEN_ROW} .label-name`; - static QUICK_OPEN_ENTRY_LABEL_SPAN = `${QuickOpen.QUICK_OPEN_ROW} .monaco-highlighted-label span`; - - constructor(private code: Code, private editors: Editors) { } + constructor(private code: Code, private editors: Editors, private quickInput: QuickInput) { } async openQuickOpen(value: string): Promise { let retries = 0; @@ -29,7 +23,7 @@ export class QuickOpen { } try { - await this.waitForQuickOpenOpened(10); + await this.quickInput.waitForQuickInputOpened(10); break; } catch (err) { if (++retries > 5) { @@ -41,63 +35,27 @@ export class QuickOpen { } if (value) { - await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, value); + await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, value); } } - async closeQuickOpen(): Promise { - await this.code.dispatchKeybinding('escape'); - await this.waitForQuickOpenClosed(); - } - async openFile(fileName: string): Promise { await this.openQuickOpen(fileName); - await this.waitForQuickOpenElements(names => names[0] === fileName); + await this.quickInput.waitForQuickInputElements(names => names[0] === fileName); await this.code.dispatchKeybinding('enter'); await this.editors.waitForActiveTab(fileName); await this.editors.waitForEditorFocus(fileName); } - async waitForQuickOpenOpened(retryCount?: number): Promise { - await this.code.waitForActiveElement(QuickOpen.QUICK_OPEN_INPUT, retryCount); - } - - private async waitForQuickOpenClosed(): Promise { - await this.code.waitForElement(QuickOpen.QUICK_OPEN, r => !!r && r.attributes.style.indexOf('display: none;') !== -1); - } - - async submit(text: string): Promise { - await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, text); - await this.code.dispatchKeybinding('enter'); - await this.waitForQuickOpenClosed(); - } - - async selectQuickOpenElement(index: number): Promise { - this.activateQuickOpenElement(index); - await this.code.dispatchKeybinding('enter'); - await this.waitForQuickOpenClosed(); - } - - async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise { - await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent))); - } - async runCommand(commandId: string): Promise { await this.openQuickOpen(`>${commandId}`); // wait for best choice to be focused - await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT); + await this.code.waitForTextContent(QuickInput.QUICK_INPUT_FOCUSED_ELEMENT); // wait and click on best choice - await this.selectQuickOpenElement(0); - } - - async activateQuickOpenElement(index: number): Promise { - await this.waitForQuickOpenOpened(); - for (let from = 0; from < index; from++) { - await this.code.dispatchKeybinding('down'); - } + await this.quickInput.selectQuickInputElement(0); } async openQuickOutline(): Promise { @@ -110,13 +68,13 @@ export class QuickOpen { await this.code.dispatchKeybinding('ctrl+shift+o'); } - const text = await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_ENTRY_LABEL_SPAN); + const text = await this.code.waitForTextContent(QuickInput.QUICK_INPUT_ENTRY_LABEL_SPAN); if (text !== 'No symbol information for the file') { return; } - await this.closeQuickOpen(); + await this.quickInput.closeQuickInput(); await new Promise(c => setTimeout(c, 250)); } } diff --git a/test/automation/src/workbench.ts b/test/automation/src/workbench.ts index 212f265ca66..51606062d91 100644 --- a/test/automation/src/workbench.ts +++ b/test/automation/src/workbench.ts @@ -44,8 +44,8 @@ export class Workbench { constructor(code: Code, userDataPath: string) { this.editors = new Editors(code); - this.quickopen = new QuickOpen(code, this.editors); this.quickinput = new QuickInput(code); + this.quickopen = new QuickOpen(code, this.editors, this.quickinput); this.explorer = new Explorer(code, this.editors); this.activitybar = new ActivityBar(code); this.search = new Search(code); diff --git a/test/smoke/src/areas/editor/editor.test.ts b/test/smoke/src/areas/editor/editor.test.ts index 8832f070225..2b5f58bf644 100644 --- a/test/smoke/src/areas/editor/editor.test.ts +++ b/test/smoke/src/areas/editor/editor.test.ts @@ -12,7 +12,7 @@ export function setup() { await app.workbench.quickopen.openFile('www'); await app.workbench.quickopen.openQuickOutline(); - await app.workbench.quickopen.waitForQuickOpenElements(names => names.length >= 6); + await app.workbench.quickinput.waitForQuickInputElements(names => names.length >= 6); }); // it('folds/unfolds the code correctly', async function () { diff --git a/test/smoke/src/areas/languages/languages.test.ts b/test/smoke/src/areas/languages/languages.test.ts index 0985a614a9e..36c9bf446dc 100644 --- a/test/smoke/src/areas/languages/languages.test.ts +++ b/test/smoke/src/areas/languages/languages.test.ts @@ -12,7 +12,7 @@ export function setup() { await app.workbench.quickopen.openFile('style.css'); await app.workbench.quickopen.openQuickOutline(); - await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 2); + await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 2); }); it('verifies problems view', async function () { diff --git a/test/smoke/src/areas/multiroot/multiroot.test.ts b/test/smoke/src/areas/multiroot/multiroot.test.ts index 0a1090a3ff5..022634a8be5 100644 --- a/test/smoke/src/areas/multiroot/multiroot.test.ts +++ b/test/smoke/src/areas/multiroot/multiroot.test.ts @@ -47,8 +47,8 @@ export function setup() { const app = this.app as Application; await app.workbench.quickopen.openQuickOpen('*.*'); - await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 6); - await app.workbench.quickopen.closeQuickOpen(); + await app.workbench.quickinput.waitForQuickInputElements(names => names.length === 6); + await app.workbench.quickinput.closeQuickInput(); }); it('shows workspace name in title', async function () { diff --git a/test/smoke/src/areas/search/search.test.ts b/test/smoke/src/areas/search/search.test.ts index 68c9e5f2854..bdd9ecc39af 100644 --- a/test/smoke/src/areas/search/search.test.ts +++ b/test/smoke/src/areas/search/search.test.ts @@ -10,8 +10,8 @@ export function setup() { describe('Search', () => { after(function () { const app = this.app as Application; - cp.execSync('git checkout .', { cwd: app.workspacePathOrFolder }); - cp.execSync('git reset --hard origin/master', { cwd: app.workspacePathOrFolder }); + cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }); + cp.execSync('git reset --hard origin/master --quiet', { cwd: app.workspacePathOrFolder }); }); it('searches for body & checks for correct result number', async function () { @@ -71,7 +71,7 @@ export function setup() { ]; await app.workbench.quickopen.openQuickOpen('.js'); - await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m))); + await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m))); await app.code.dispatchKeybinding('escape'); }); @@ -84,7 +84,7 @@ export function setup() { ]; await app.workbench.quickopen.openQuickOpen('a.s'); - await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m))); + await app.workbench.quickinput.waitForQuickInputElements(names => expectedNames.every(n => names.some(m => n === m))); await app.code.dispatchKeybinding('escape'); }); }); diff --git a/test/smoke/src/areas/statusbar/statusbar.test.ts b/test/smoke/src/areas/statusbar/statusbar.test.ts index 34ea9661154..5c5a3700bfb 100644 --- a/test/smoke/src/areas/statusbar/statusbar.test.ts +++ b/test/smoke/src/areas/statusbar/statusbar.test.ts @@ -77,9 +77,9 @@ export function setup(isWeb) { await app.workbench.quickopen.openFile('app.js'); await app.workbench.statusbar.clickOn(StatusBarElement.SELECTION_STATUS); - await app.workbench.quickopen.waitForQuickOpenOpened(); + await app.workbench.quickinput.waitForQuickInputOpened(); - await app.workbench.quickopen.submit(':15'); + await app.workbench.quickinput.submit(':15'); await app.workbench.editor.waitForHighlightingLine('app.js', 15); });