quick access - cleanup API for quick input
parent
ebe1981e8e
commit
21431f6117
|
@ -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<void> {
|
||||
await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, text);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickInputClosed();
|
||||
}
|
||||
|
||||
async closeQuickInput(): Promise<void> {
|
||||
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<void> {
|
||||
async waitForQuickInputElements(accept: (names: string[]) => boolean): Promise<void> {
|
||||
await this.code.waitForElements(QuickInput.QUICK_INPUT_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent)));
|
||||
}
|
||||
|
||||
async waitForQuickInputClosed(): Promise<void> {
|
||||
await this.code.waitForElement(QuickInput.QUICK_INPUT, r => !!r && r.attributes.style.indexOf('display: none;') !== -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<void> {
|
||||
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<void> {
|
||||
await this.code.dispatchKeybinding('escape');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async openFile(fileName: string): Promise<void> {
|
||||
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<void> {
|
||||
await this.code.waitForActiveElement(QuickOpen.QUICK_OPEN_INPUT, retryCount);
|
||||
}
|
||||
|
||||
private async waitForQuickOpenClosed(): Promise<void> {
|
||||
await this.code.waitForElement(QuickOpen.QUICK_OPEN, r => !!r && r.attributes.style.indexOf('display: none;') !== -1);
|
||||
}
|
||||
|
||||
async submit(text: string): Promise<void> {
|
||||
await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, text);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async selectQuickOpenElement(index: number): Promise<void> {
|
||||
this.activateQuickOpenElement(index);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
await this.waitForQuickOpenClosed();
|
||||
}
|
||||
|
||||
async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise<void> {
|
||||
await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent)));
|
||||
}
|
||||
|
||||
async runCommand(commandId: string): Promise<void> {
|
||||
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<void> {
|
||||
await this.waitForQuickOpenOpened();
|
||||
for (let from = 0; from < index; from++) {
|
||||
await this.code.dispatchKeybinding('down');
|
||||
}
|
||||
await this.quickInput.selectQuickInputElement(0);
|
||||
}
|
||||
|
||||
async openQuickOutline(): Promise<void> {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue