Skip to content

Commit

Permalink
issue-920: Workbench().executeCommand executes always the first comma…
Browse files Browse the repository at this point in the history
…nd from quickPicks (#1004)

Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek authored Nov 20, 2023
1 parent 1e92c26 commit 30cdc10
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
7 changes: 6 additions & 1 deletion page-objects/src/components/workbench/Workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ export class Workbench extends AbstractElement {
async executeCommand(command: string): Promise<void> {
const prompt = await this.openCommandPrompt();
await prompt.setText(`>${command}`);
await prompt.confirm();
const quickPicks = await Promise.all((await prompt.getQuickPicks()).map(item => item.getLabel()));
if(quickPicks.includes(command)) {
await prompt.selectQuickPick(command);
} else {
await prompt.confirm();
}
}
}
5 changes: 5 additions & 0 deletions test/test-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"title": "Hello World",
"icon": "$(rocket)"
},
{
"command": "extension.helloWorld2",
"title": "Hello a World",
"icon": "$(rocket)"
},
{
"command": "extension.warningMsg",
"title": "Warning Message"
Expand Down
14 changes: 10 additions & 4 deletions test/test-project/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { TreeView } from './treeView';
export const ERROR_MESSAGE_COMMAND = 'extension.errorMsg';

export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
vscode.window.showInformationMessage('Hello World!');
});
let openCommand = vscode.commands.registerCommand('extension.openFile', async () => {
const document = await vscode.workspace.openTextDocument(vscode.Uri.file(
path.resolve(__dirname, '..', '..', 'resources', 'test-file.ts')));
Expand All @@ -36,7 +33,16 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.showQuickPick(['test1', 'test2', 'test3'], { canPickMany: true, ignoreFocusOut: true });
});

context.subscriptions.push(disposable);
context.subscriptions.push(
vscode.commands.registerCommand('extension.helloWorld', () => {
vscode.window.showInformationMessage('Hello World!');
})
);
context.subscriptions.push(
vscode.commands.registerCommand('extension.helloWorld2', () => {
vscode.window.showInformationMessage('Hello World, Test Project!');
})
);
context.subscriptions.push(openCommand);
context.subscriptions.push(openFolder);
context.subscriptions.push(closeFolder);
Expand Down
5 changes: 4 additions & 1 deletion test/test-project/src/test/workbench/workbench-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ describe('Workbench', () => {
});

it('executeCommand works', async () => {
await bench.executeCommand('hello world');
await bench.executeCommand('Hello World');
await bench.getDriver().sleep(500);
const notifications = await bench.getNotifications();
expect(notifications).not.empty;

const message = await notifications[0].getMessage();
expect(message).is.equal('Hello World!');
});

it('openSettings opens the settings editor', async function() {
Expand Down

0 comments on commit 30cdc10

Please sign in to comment.