Skip to content

Commit 4f0b2b0

Browse files
author
Benjamin Pasero
committed
tests - fix smoketests for new quick open impl
1 parent 80b0200 commit 4f0b2b0

5 files changed

Lines changed: 29 additions & 20 deletions

File tree

src/vs/platform/quickinput/browser/commandsQuickAccess.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
6161
const labelHighlights = withNullAsUndefined(AbstractCommandsQuickAccessProvider.WORD_FILTER(filter, commandPick.label));
6262
const aliasHighlights = commandPick.commandAlias ? withNullAsUndefined(AbstractCommandsQuickAccessProvider.WORD_FILTER(filter, commandPick.commandAlias)) : undefined;
6363

64+
// Add if matching in label or alias
6465
if (labelHighlights || aliasHighlights) {
6566
commandPick.highlights = {
6667
label: labelHighlights,
@@ -69,6 +70,11 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
6970

7071
filteredCommandPicks.push(commandPick);
7172
}
73+
74+
// Also add if we have a 100% command ID match
75+
else if (filter === commandPick.commandId) {
76+
filteredCommandPicks.push(commandPick);
77+
}
7278
}
7379

7480
// Add description to commands that have duplicate labels

test/automation/src/quickinput.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export class QuickInput {
99

1010
static QUICK_INPUT = '.quick-input-widget';
1111
static QUICK_INPUT_INPUT = `${QuickInput.QUICK_INPUT} .quick-input-box input`;
12-
static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
1312

1413
constructor(private code: Code) { }
1514

test/automation/src/quickopen.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { Code } from './code';
88

99
export class QuickOpen {
1010

11-
static QUICK_OPEN = 'div.monaco-quick-open-widget';
12-
static QUICK_OPEN_HIDDEN = 'div.monaco-quick-open-widget[aria-hidden="true"]';
13-
static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input`;
14-
static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
15-
static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
16-
static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name';
11+
static QUICK_OPEN = '.quick-input-widget';
12+
static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-input-box input`;
13+
static QUICK_OPEN_ROW = `${QuickOpen.QUICK_OPEN} .quick-input-list .monaco-list-row`;
14+
static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN_ROW}.focused .monaco-highlighted-label`;
15+
static QUICK_OPEN_ENTRY_LABEL = `${QuickOpen.QUICK_OPEN_ROW} .label-name`;
16+
static QUICK_OPEN_ENTRY_LABEL_SPAN = `${QuickOpen.QUICK_OPEN_ROW} .monaco-highlighted-label span`;
1717

1818
constructor(private code: Code, private editors: Editors) { }
1919

@@ -64,7 +64,7 @@ export class QuickOpen {
6464
}
6565

6666
private async waitForQuickOpenClosed(): Promise<void> {
67-
await this.code.waitForElement(QuickOpen.QUICK_OPEN_HIDDEN);
67+
await this.code.waitForElement(QuickOpen.QUICK_OPEN, r => !!r && r.attributes.style.indexOf('display: none;') !== -1);
6868
}
6969

7070
async submit(text: string): Promise<void> {
@@ -74,26 +74,30 @@ export class QuickOpen {
7474
}
7575

7676
async selectQuickOpenElement(index: number): Promise<void> {
77-
await this.waitForQuickOpenOpened();
78-
for (let from = 0; from < index; from++) {
79-
await this.code.dispatchKeybinding('down');
80-
}
77+
this.activateQuickOpenElement(index);
8178
await this.code.dispatchKeybinding('enter');
8279
await this.waitForQuickOpenClosed();
8380
}
8481

8582
async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise<void> {
86-
await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL_SELECTOR, false, els => accept(els.map(e => e.textContent)));
83+
await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent)));
8784
}
8885

89-
async runCommand(command: string): Promise<void> {
90-
await this.openQuickOpen(`> ${command}`);
86+
async runCommand(commandId: string): Promise<void> {
87+
await this.openQuickOpen(`>${commandId}`);
9188

9289
// wait for best choice to be focused
93-
await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT, command);
90+
await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT);
9491

9592
// wait and click on best choice
96-
await this.code.waitAndClick(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT);
93+
await this.selectQuickOpenElement(0);
94+
}
95+
96+
async activateQuickOpenElement(index: number): Promise<void> {
97+
await this.waitForQuickOpenOpened();
98+
for (let from = 0; from < index; from++) {
99+
await this.code.dispatchKeybinding('down');
100+
}
97101
}
98102

99103
async openQuickOutline(): Promise<void> {
@@ -106,7 +110,7 @@ export class QuickOpen {
106110
await this.code.dispatchKeybinding('ctrl+shift+o');
107111
}
108112

109-
const text = await this.code.waitForTextContent('div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties div.monaco-tree-row .quick-open-entry .monaco-icon-label .label-name .monaco-highlighted-label span');
113+
const text = await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_ENTRY_LABEL_SPAN);
110114

111115
if (text !== 'No symbol information for the file') {
112116
return;

test/automation/src/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class SettingsEditor {
3232
}
3333

3434
private async openSettings(): Promise<void> {
35-
await this.quickopen.runCommand('Preferences: Open Settings (JSON)');
35+
await this.quickopen.runCommand('workbench.action.openSettingsJson');
3636
}
3737
}

test/automation/src/terminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Terminal {
1515
constructor(private code: Code, private quickopen: QuickOpen) { }
1616

1717
async showTerminal(): Promise<void> {
18-
await this.quickopen.runCommand('View: Toggle Integrated Terminal');
18+
await this.quickopen.runCommand('workbench.action.terminal.toggleTerminal');
1919
await this.code.waitForActiveElement(XTERM_TEXTAREA);
2020
await this.code.waitForTerminalBuffer(XTERM_SELECTOR, lines => lines.some(line => line.length > 0));
2121
}

0 commit comments

Comments
 (0)