From bd41b74fd17a2dde33fd129b113a68fe8b25530e Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sun, 8 Oct 2023 16:47:51 -0700 Subject: [PATCH] Dedupe strings in tf-idf index & include `exactLabelMatch` in `runCommand` in smoke tests (#195085) --- src/vs/platform/quickinput/browser/commandsQuickAccess.ts | 4 ++-- test/automation/src/extensions.ts | 2 +- test/automation/src/quickaccess.ts | 7 +++++-- test/automation/src/task.ts | 2 +- test/automation/src/terminal.ts | 6 +++--- test/automation/src/workbench.ts | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/vs/platform/quickinput/browser/commandsQuickAccess.ts b/src/vs/platform/quickinput/browser/commandsQuickAccess.ts index aeb7c3878f5..87a211bcfbf 100644 --- a/src/vs/platform/quickinput/browser/commandsQuickAccess.ts +++ b/src/vs/platform/quickinput/browser/commandsQuickAccess.ts @@ -286,10 +286,10 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc // TF-IDF string to be indexed private getTfIdfChunk({ label, commandAlias, commandDescription }: ICommandQuickPick) { let chunk = label; - if (commandAlias) { + if (commandAlias && commandAlias !== label) { chunk += ` - ${commandAlias}`; } - if (commandDescription) { + if (commandDescription && commandDescription.value !== label) { // If the original is the same as the value, don't add it chunk += ` - ${commandDescription.value === commandDescription.original ? commandDescription.value : `${commandDescription.value} (${commandDescription.original})`}`; } diff --git a/test/automation/src/extensions.ts b/test/automation/src/extensions.ts index 08bb4585f61..aa59f7cd7cf 100644 --- a/test/automation/src/extensions.ts +++ b/test/automation/src/extensions.ts @@ -19,7 +19,7 @@ export class Extensions extends Viewlet { } async searchForExtension(id: string): Promise { - await this.commands.runCommand('workbench.extensions.action.focusExtensionsView'); + await this.commands.runCommand('Extensions: Focus on Extensions View', { exactLabelMatch: true }); await this.code.waitForTypeInEditor('div.extensions-viewlet[id="workbench.view.extensions"] .monaco-editor textarea', `@id:${id}`); await this.code.waitForTextContent(`div.part.sidebar div.composite.title h2`, 'Extensions: Marketplace'); diff --git a/test/automation/src/quickaccess.ts b/test/automation/src/quickaccess.ts index 4c0f1079db1..a2b447e0c8d 100644 --- a/test/automation/src/quickaccess.ts +++ b/test/automation/src/quickaccess.ts @@ -170,9 +170,12 @@ export class QuickAccess { } } - async runCommand(commandId: string, keepOpen?: boolean): Promise { + async runCommand(commandId: string, options?: { keepOpen?: boolean; exactLabelMatch?: boolean }): Promise { let retries = 0; + const keepOpen = options?.keepOpen; + const exactLabelMatch = options?.exactLabelMatch; + while (++retries < 5) { // open commands picker @@ -183,7 +186,7 @@ export class QuickAccess { // Retry for as long as the command not found const text = await this.quickInput.waitForQuickInputElementText(); - if (text === 'No matching commands') { + if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) { this.code.logger.log(`QuickAccess: No matching commands, will retry...`); await this.quickInput.closeQuickInput(); await this.code.wait(1000); diff --git a/test/automation/src/task.ts b/test/automation/src/task.ts index 1bccb05d913..ab95e9947d5 100644 --- a/test/automation/src/task.ts +++ b/test/automation/src/task.ts @@ -35,7 +35,7 @@ export class Task { async assertTasks(filter: string, expected: ITaskConfigurationProperties[], type: 'run' | 'configure') { await this.code.dispatchKeybinding('right'); await this.editors.saveOpenedFile(); - type === 'run' ? await this.quickaccess.runCommand('workbench.action.tasks.runTask', true) : await this.quickaccess.runCommand('workbench.action.tasks.configureTask', true); + type === 'run' ? await this.quickaccess.runCommand('workbench.action.tasks.runTask', { keepOpen: true }) : await this.quickaccess.runCommand('workbench.action.tasks.configureTask', { keepOpen: true }); if (expected.length === 0) { await this.quickinput.waitForQuickInputElements(e => e.length > 1 && e.every(label => label.trim() !== filter.trim())); } else { diff --git a/test/automation/src/terminal.ts b/test/automation/src/terminal.ts index e0604a5b45f..8a8a6bac884 100644 --- a/test/automation/src/terminal.ts +++ b/test/automation/src/terminal.ts @@ -80,7 +80,7 @@ export class Terminal { async runCommand(commandId: TerminalCommandId, expectedLocation?: 'editor' | 'panel'): Promise { const keepOpen = commandId === TerminalCommandId.Join; - await this.quickaccess.runCommand(commandId, keepOpen); + await this.quickaccess.runCommand(commandId, { keepOpen }); if (keepOpen) { await this.code.dispatchKeybinding('enter'); await this.quickinput.waitForQuickInputClosed(); @@ -106,8 +106,8 @@ export class Terminal { } async runCommandWithValue(commandId: TerminalCommandIdWithValue, value?: string, altKey?: boolean): Promise { - const shouldKeepOpen = !!value || commandId === TerminalCommandIdWithValue.NewWithProfile || commandId === TerminalCommandIdWithValue.Rename || (commandId === TerminalCommandIdWithValue.SelectDefaultProfile && value !== 'PowerShell'); - await this.quickaccess.runCommand(commandId, shouldKeepOpen); + const keepOpen = !!value || commandId === TerminalCommandIdWithValue.NewWithProfile || commandId === TerminalCommandIdWithValue.Rename || (commandId === TerminalCommandIdWithValue.SelectDefaultProfile && value !== 'PowerShell'); + await this.quickaccess.runCommand(commandId, { keepOpen }); // Running the command should hide the quick input in the following frame, this next wait // ensures that the quick input is opened again before proceeding to avoid a race condition // where the enter keybinding below would close the quick input if it's triggered before the diff --git a/test/automation/src/workbench.ts b/test/automation/src/workbench.ts index ffb628d16fd..34905874310 100644 --- a/test/automation/src/workbench.ts +++ b/test/automation/src/workbench.ts @@ -24,7 +24,7 @@ import { Localization } from './localization'; import { Task } from './task'; export interface Commands { - runCommand(command: string): Promise; + runCommand(command: string, options?: { exactLabelMatch?: boolean }): Promise; } export class Workbench {