mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
One common source of flakiness is just dispatching a keybinding and not verifying it did its thing. This change adds a few accept functions and also forces callers to provide an async function so that the caller considers adding one as it's the norm, not the edge case. Fixes #246731
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Viewlet } from './viewlet';
|
|
import { Code } from './code';
|
|
|
|
export class Explorer extends Viewlet {
|
|
|
|
private static readonly EXPLORER_VIEWLET = 'div[id="workbench.view.explorer"]';
|
|
private static readonly OPEN_EDITORS_VIEW = `${Explorer.EXPLORER_VIEWLET} .split-view-view:nth-child(1) .title`;
|
|
|
|
constructor(code: Code) {
|
|
super(code);
|
|
}
|
|
|
|
async openExplorerView(): Promise<any> {
|
|
await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+e' : 'ctrl+shift+e', async () => {
|
|
await this.code.waitForElement(Explorer.EXPLORER_VIEWLET);
|
|
});
|
|
}
|
|
|
|
async waitForOpenEditorsViewTitle(fn: (title: string) => boolean): Promise<void> {
|
|
await this.code.waitForTextContent(Explorer.OPEN_EDITORS_VIEW, undefined, fn);
|
|
}
|
|
|
|
getExtensionSelector(fileName: string): string {
|
|
const extension = fileName.split('.')[1];
|
|
if (extension === 'js') {
|
|
return 'js-ext-file-icon ext-file-icon javascript-lang-file-icon';
|
|
} else if (extension === 'json') {
|
|
return 'json-ext-file-icon ext-file-icon json-lang-file-icon';
|
|
} else if (extension === 'md') {
|
|
return 'md-ext-file-icon ext-file-icon markdown-lang-file-icon';
|
|
}
|
|
throw new Error('No class defined for this file extension');
|
|
}
|
|
|
|
}
|