Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/automation/src/keybindings.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Code } from './code';
7
8
const SEARCH_INPUT = '.keybindings-header .settings-search-input input';
9
10
export class KeybindingsEditor {
11
12
constructor(private code: Code) { }
13
14
async updateKeybinding(command: string, commandName: string | undefined, keybinding: string, keybindingTitle: string): Promise<any> {
15
const accept = () => this.code.waitForActiveElement(SEARCH_INPUT);
16
if (process.platform === 'darwin') {
17
await this.code.dispatchKeybinding('cmd+k cmd+s', accept);
18
} else {
19
await this.code.dispatchKeybinding('ctrl+k ctrl+s', accept);
20
}
21
22
await this.code.waitForActiveElement(SEARCH_INPUT);
23
await this.code.waitForSetValue(SEARCH_INPUT, `@command:${command}`);
24
25
const commandTitle = commandName ? `${commandName} (${command})` : command;
26
await this.code.waitAndClick(`.keybindings-table-container .monaco-list-row .command[aria-label="${commandTitle}"]`);
27
await this.code.waitForElement(`.keybindings-table-container .monaco-list-row.focused.selected .command[aria-label="${commandTitle}"]`);
28
await this.code.dispatchKeybinding('enter', () => this.code.waitForActiveElement('.defineKeybindingWidget .monaco-inputbox input'));
29
await this.code.dispatchKeybinding(keybinding, async () => { }); // No accept cb is fine as the following keybinding verifies
30
await this.code.dispatchKeybinding('enter', async () => { await this.code.waitForElement(`.keybindings-table-container .keybinding-label div[aria-label="${keybindingTitle}"]`); });
31
}
32
}
33
34