From c975f896b5f2b85b8210626ec05e6d6e75ac15c2 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 16 Aug 2019 15:35:36 -0700 Subject: [PATCH] Fix format --- src/client/common/process/logger.ts | 6 ++- uitests/src/helpers/extensions.ts | 5 +-- uitests/src/helpers/misc.ts | 4 +- uitests/src/helpers/python.ts | 10 +---- uitests/src/helpers/unzip.ts | 6 +-- uitests/src/index.ts | 28 ++++---------- uitests/src/selectors.ts | 27 +++++-------- uitests/src/setup/downloader.ts | 34 +++-------------- uitests/src/setup/driver.ts | 59 +++++------------------------ uitests/src/setup/environment.ts | 5 +-- uitests/src/setup/setup.ts | 37 ++++-------------- uitests/src/steps/core.ts | 4 +- uitests/src/steps/debugger.ts | 5 +-- uitests/src/steps/documents.ts | 5 +-- uitests/src/steps/main.ts | 21 ++-------- uitests/src/steps/notifications.ts | 10 +---- uitests/src/steps/outputPanel.ts | 11 +----- uitests/src/steps/problems.ts | 4 +- uitests/src/steps/settings.ts | 50 +++++------------------- uitests/src/steps/statusbar.ts | 4 +- uitests/src/steps/testing.ts | 14 ++----- uitests/src/testRunner.ts | 44 ++++----------------- uitests/src/types.ts | 17 ++------- uitests/src/vscode/application.ts | 4 +- uitests/src/vscode/debugger.ts | 3 +- uitests/src/vscode/documents.ts | 12 ++---- uitests/src/vscode/notifications.ts | 13 ++----- uitests/src/vscode/quickOpen.ts | 30 +++------------ uitests/src/vscode/settings.ts | 16 ++------ uitests/src/vscode/testExplorer.ts | 24 ++++-------- 30 files changed, 107 insertions(+), 405 deletions(-) diff --git a/src/client/common/process/logger.ts b/src/client/common/process/logger.ts index b2618a688a75a..5ccb4eb1a0ab4 100644 --- a/src/client/common/process/logger.ts +++ b/src/client/common/process/logger.ts @@ -19,7 +19,11 @@ export class ProcessLogger implements IProcessLogger { ) {} public logProcess(file: string, args: string[], options?: SpawnOptions) { - if (!isTestExecution() && isCI && !workspace.getConfiguration('python', null).get('enableProcessLogging', true)) { + if ( + !isTestExecution() && + isCI && + !workspace.getConfiguration('python', null).get('enableProcessLogging', true) + ) { return; } const argsList = args.reduce((accumulator, current, index) => { diff --git a/uitests/src/helpers/extensions.ts b/uitests/src/helpers/extensions.ts index c76aeaf790ee9..612e91fbdbc41 100644 --- a/uitests/src/helpers/extensions.ts +++ b/uitests/src/helpers/extensions.ts @@ -71,10 +71,7 @@ String.prototype.normalize = function(this: string, ...args: []): string { * By default lines are trimmed and empty lines are removed. * @param {SplitLinesOptions=} splitOptions - Options used for splitting the string. */ -String.prototype.splitLines = function( - this: string, - splitOptions: { trim: boolean; removeEmptyEntries: boolean } = { removeEmptyEntries: true, trim: true } -): string[] { +String.prototype.splitLines = function(this: string, splitOptions: { trim: boolean; removeEmptyEntries: boolean } = { removeEmptyEntries: true, trim: true }): string[] { let lines = this.split(/\r?\n/g); if (splitOptions && splitOptions.trim) { lines = lines.map(line => line.trim()); diff --git a/uitests/src/helpers/misc.ts b/uitests/src/helpers/misc.ts index f4f6a8ebe9dc0..cd1f02c0f15de 100644 --- a/uitests/src/helpers/misc.ts +++ b/uitests/src/helpers/misc.ts @@ -72,9 +72,7 @@ export async function retryWrapper( ): Promise>> { const watch = new StopWatch(); const interval = options.interval || 100; - const iterations = (options as RetryTimeoutOptions).timeout - ? (options as RetryTimeoutOptions).timeout / interval - : (options as RetryCounterOptions).count; + const iterations = (options as RetryTimeoutOptions).timeout ? (options as RetryTimeoutOptions).timeout / interval : (options as RetryCounterOptions).count; const timeout = (options as RetryTimeoutOptions).timeout || (options as RetryCounterOptions).count * interval; let lastEx: Error | undefined; diff --git a/uitests/src/helpers/python.ts b/uitests/src/helpers/python.ts index 48b4bc80ec3f8..72691752542dd 100644 --- a/uitests/src/helpers/python.ts +++ b/uitests/src/helpers/python.ts @@ -28,16 +28,10 @@ export async function installPackage(pythonPath: string, moduleName: string): Pr export async function uninstallModule(pythonPath: string, moduleName: string): Promise { await installOrUninstallPackage(pythonPath, moduleName, false); } -export async function installOrUninstallPackage( - pythonPath: string, - moduleName: string, - install: boolean = true -): Promise { +export async function installOrUninstallPackage(pythonPath: string, moduleName: string, install: boolean = true): Promise { const installCmd = install ? 'install' : 'uninstall'; const extraArgs = install ? [] : ['-y']; - const cmd = `${pythonPath.toCommandArgument()} -m pip ${installCmd} ${moduleName} -q --disable-pip-version-check ${extraArgs.join( - ' ' - )}`; + const cmd = `${pythonPath.toCommandArgument()} -m pip ${installCmd} ${moduleName} -q --disable-pip-version-check ${extraArgs.join(' ')}`; // tslint:disable-next-line: no-unnecessary-callback-wrapper return new Promise(resolve => exec(cmd.trim(), () => resolve())); } diff --git a/uitests/src/helpers/unzip.ts b/uitests/src/helpers/unzip.ts index 5332298cdcf98..70189c589d973 100644 --- a/uitests/src/helpers/unzip.ts +++ b/uitests/src/helpers/unzip.ts @@ -37,11 +37,7 @@ export async function unzipFile(zipFile: string, targetFolder: string) { export async function unzipTarGz(zipFile: string, targetFolder: string) { debug(`Unzip (unzipTarGz) ${zipFile} into ${targetFolder}`); - const fileToFixPermissions = [ - 'VSCode-linux-x64/code', - 'VSCode-linux-x64/code-insiders', - 'VSCode-linux-x64/resources/app/node_modules*/vscode-ripgrep/**/rg' - ]; + const fileToFixPermissions = ['VSCode-linux-x64/code', 'VSCode-linux-x64/code-insiders', 'VSCode-linux-x64/resources/app/node_modules*/vscode-ripgrep/**/rg']; await fs.ensureDir(targetFolder); await new Promise((resolve, reject) => { const gulpFilter = filter(fileToFixPermissions, { restore: true }); diff --git a/uitests/src/index.ts b/uitests/src/index.ts index 180a00c78b61a..58ae67b86f7fb 100644 --- a/uitests/src/index.ts +++ b/uitests/src/index.ts @@ -9,13 +9,7 @@ import * as yargs from 'yargs'; import { sleep } from './helpers'; import { info, initialize } from './helpers/logger'; import { mergeAndgenerateHtmlReport } from './helpers/report'; -import { - downloadVSCode, - getTestOptions, - installExtensions, - TestOptions, - waitForPythonExtensionToActivate -} from './setup'; +import { downloadVSCode, getTestOptions, installExtensions, TestOptions, waitForPythonExtensionToActivate } from './setup'; import { start } from './testRunner'; import { Channel } from './types'; import { Application } from './vscode'; @@ -112,14 +106,8 @@ const parsedArgs = yargs .example('test', ' # (Runs all tests in stable)') .example('test', '--channel=insider # (Runs all tests in insiders)') .example('test', '--channel=insider --pythonPath=c:/python/python.exe # (Runs all tests in insiders)') - .example( - 'test', - "-- --tags=@wip # (Runs tests in stable with with tags @wip. Arguments after '--' are cucumberjs args.)" - ) - .example( - 'test', - "-- --tags='@smoke and @terminal' # (Runs tests in stable with tags '@smoke and @terminal')" - ), + .example('test', "-- --tags=@wip # (Runs tests in stable with with tags @wip. Arguments after '--' are cucumberjs args.)") + .example('test', "-- --tags='@smoke and @terminal' # (Runs tests in stable with tags '@smoke and @terminal')"), handler: async argv => { initialize(argv.verbose); const cucumberArgs = argv._.slice(1); @@ -130,12 +118,10 @@ const parsedArgs = yargs .toString() .trim() : argv.pythonPath; - await start(argv.channel, path.resolve(argv.destination), argv.verbose, pythonPath, cucumberArgs).catch( - ex => { - console.error('UI Tests Failed', ex); - process.exit(1); // Required for CLI to fail on CI servers. - } - ); + await start(argv.channel, path.resolve(argv.destination), argv.verbose, pythonPath, cucumberArgs).catch(ex => { + console.error('UI Tests Failed', ex); + process.exit(1); // Required for CLI to fail on CI servers. + }); } }) .command({ diff --git a/uitests/src/selectors.ts b/uitests/src/selectors.ts index 57b49bdddd631..45819dec145d2 100644 --- a/uitests/src/selectors.ts +++ b/uitests/src/selectors.ts @@ -172,10 +172,8 @@ export class QuickOpen { public static QUICK_OPEN_HIDDEN = 'div.monaco-quick-open-widget[aria-hidden="true"]'; public static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input`; public static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`; - public static QUICK_OPEN_ENTRY_SELECTOR = - 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry'; - public static QUICK_OPEN_ENTRY_LABEL_SELECTOR = - 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name'; + public static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry'; + public static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name'; public static QUICK_OPEN_ENTRY_LINE_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .monaco-label-description-container .label-name .monaco-highlighted-label span'; } @@ -230,23 +228,19 @@ const selectors: Record = { stable: '.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded' }, [Selector.NotificationError]: { - stable: - '.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded .notification-list-item-icon.icon-error' + stable: '.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded .notification-list-item-icon.icon-error' }, [Selector.NthNotificationMessage]: { - stable: - '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded div.notification-list-item-message span' + stable: '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded div.notification-list-item-message span' }, [Selector.IndividualNotification]: { stable: messageBoxSelector }, [Selector.CloseButtonInNthNotification]: { - stable: - '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .action-label.icon.clear-notification-action' + stable: '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .action-label.icon.clear-notification-action' }, [Selector.ButtonInNthNotification]: { - stable: - ".notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .monaco-button.monaco-text-button[title='{1}']" + stable: ".notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .monaco-button.monaco-text-button[title='{1}']" }, [Selector.ProblemsBadge]: { stable: '.part.panel.bottom .action-item.checked .badge-content' @@ -261,12 +255,10 @@ const selectors: Record = { stable: `${quickOpen} .quick-open-input input` }, [Selector.QuickOpenEntryLabel]: { - stable: - 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name' + stable: 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name' }, [Selector.QuickOpenEntryLabelFocused]: { - stable: - 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .label-name .monaco-highlighted-label .highlight' + stable: 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .label-name .monaco-highlighted-label .highlight' }, [Selector.QuickOpenEntryLineLabel]: { stable: QuickOpen.QUICK_OPEN_ENTRY_LINE_LABEL_SELECTOR @@ -293,8 +285,7 @@ const selectors: Record = { stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) a.label-name' }, [Selector.NthTestExplorerNodeIcon]: { - stable: - 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) .custom-view-tree-node-item-icon' + stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) .custom-view-tree-node-item-icon' }, [Selector.NthTestExplorerNode]: { stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0})' diff --git a/uitests/src/setup/downloader.ts b/uitests/src/setup/downloader.ts index 0c97c4f7490e9..71a25a584479a 100644 --- a/uitests/src/setup/downloader.ts +++ b/uitests/src/setup/downloader.ts @@ -47,19 +47,9 @@ export function getVSCodeExecutablePath(channel: Channel, testDir: string) { if (process.platform === 'win32') { return path.join(testDir, channel, channel === 'stable' ? 'Code.exe' : 'Code - Insiders.exe'); } else if (process.platform === 'darwin') { - return path.join( - testDir, - channel, - channel === 'stable' - ? 'Visual Studio Code.app/Contents/MacOS/Electron' - : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron' - ); + return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app/Contents/MacOS/Electron' : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron'); } else { - return path.join( - testDir, - channel, - channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders' - ); + return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders'); } } @@ -75,19 +65,9 @@ export function getVSCodeElectronPath(channel: Channel, testDir: string) { if (process.platform === 'win32') { return path.join(testDir, channel, channel === 'stable' ? 'Code.exe' : 'Code - Insiders.exe'); } else if (process.platform === 'darwin') { - return path.join( - testDir, - channel, - channel === 'stable' - ? 'Visual Studio Code.app/Contents/MacOS/Electron' - : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron' - ); + return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app/Contents/MacOS/Electron' : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron'); } else { - return path.join( - testDir, - channel, - channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders' - ); + return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders'); } } @@ -103,11 +83,7 @@ export function getVSCodeDirectory(channel: Channel, testDir: string) { if (process.platform === 'win32') { return path.join(testDir, channel); } else if (process.platform === 'darwin') { - return path.join( - testDir, - channel, - channel === 'stable' ? 'Visual Studio Code.app' : 'Visual Studio Code - Insiders.app' - ); + return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app' : 'Visual Studio Code - Insiders.app'); } else { return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64' : 'VSCode-linux-x64'); } diff --git a/uitests/src/setup/driver.ts b/uitests/src/setup/driver.ts index 1554170220844..caf24847aaf1d 100644 --- a/uitests/src/setup/driver.ts +++ b/uitests/src/setup/driver.ts @@ -5,28 +5,13 @@ import { ChildProcess } from 'child_process'; import { EventEmitter } from 'events'; -import { - Browser, - ClickOptions, - ElementHandle, - launch, - Page, - UnwrapElementHandle, - WrapElementHandle -} from 'puppeteer-core'; +import { Browser, ClickOptions, ElementHandle, launch, Page, UnwrapElementHandle, WrapElementHandle } from 'puppeteer-core'; import { URI } from 'vscode-uri'; import { isCI } from '../constants'; import { noop, RetryOptions, retryWrapper, sleep } from '../helpers'; import { debug, warn } from '../helpers/logger'; import { getSelector, Selector } from '../selectors'; -import { - ElementsSelectorPredicate, - IDriver, - ITestOptions, - SelectorRetryOptions, - WaitForSelectorOptions, - WaitForSelectorOptionsHidden -} from '../types'; +import { ElementsSelectorPredicate, IDriver, ITestOptions, SelectorRetryOptions, WaitForSelectorOptions, WaitForSelectorOptionsHidden } from '../types'; import { getVSCodeElectronPath } from './downloader'; // Time to wait for UI to react to user typing in a textbox. @@ -204,10 +189,7 @@ export class Driver extends EventEmitter implements IDriver { this.process = undefined; } public async waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise; - public async waitForSelector( - selector: string, - options?: WaitForSelectorOptionsHidden - ): Promise; + public async waitForSelector(selector: string, options?: WaitForSelectorOptionsHidden): Promise; public async waitForSelector( selector: string, options?: WaitForSelectorOptions | WaitForSelectorOptionsHidden @@ -223,13 +205,7 @@ export class Driver extends EventEmitter implements IDriver { // tslint:disable-next-line: no-any public async $(selector: string, options?: SelectorRetryOptions): Promise { if (!options) { - return this.mainPage - .$(selector) - .then(ele => - ele - ? Promise.resolve(ele) - : Promise.reject(new Error(`Element not found with selector '${selector}'`)) - ); + return this.mainPage.$(selector).then(ele => (ele ? Promise.resolve(ele) : Promise.reject(new Error(`Element not found with selector '${selector}'`)))); } const wrapper = async (): Promise => { const ele = await this.mainPage.$(selector); @@ -241,10 +217,7 @@ export class Driver extends EventEmitter implements IDriver { }; return retryWrapper(Driver.toRetryOptions(options, `Failed to find for selector '${selector}'`), wrapper); } - public async $$( - selector: string, - options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate } - ): Promise { + public async $$(selector: string, options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate }): Promise { if (!options) { return this.mainPage.$$(selector); } @@ -262,15 +235,8 @@ export class Driver extends EventEmitter implements IDriver { return retryWrapper(Driver.toRetryOptions(options, `Failed to find for selector '${selector}'`), wrapper); } - public $eval( - selector: string, - pageFunction: (element: Element) => R | Promise - ): Promise>; - public $eval( - selector: string, - pageFunction: (element: Element, x1: UnwrapElementHandle) => R | Promise, - x1: X1 - ): Promise>; + public $eval(selector: string, pageFunction: (element: Element) => R | Promise): Promise>; + public $eval(selector: string, pageFunction: (element: Element, x1: UnwrapElementHandle) => R | Promise, x1: X1): Promise>; // tslint:disable-next-line: no-any public $eval(selector: any, pageFunction: any, x1?: any) { if (arguments.length === 3) { @@ -279,15 +245,8 @@ export class Driver extends EventEmitter implements IDriver { return this.mainPage.$eval(selector, pageFunction); } - public $$eval( - selector: string, - pageFunction: (elements: Element[]) => R | Promise - ): Promise>; - public $$eval( - selector: string, - pageFunction: (elements: Element[], x1: UnwrapElementHandle) => R | Promise, - x1: X1 - ): Promise>; + public $$eval(selector: string, pageFunction: (elements: Element[]) => R | Promise): Promise>; + public $$eval(selector: string, pageFunction: (elements: Element[], x1: UnwrapElementHandle) => R | Promise, x1: X1): Promise>; // tslint:disable-next-line: no-any public $$eval(selector: any, pageFunction: any, x1?: any) { return this.mainPage.$$eval(selector, pageFunction, x1); diff --git a/uitests/src/setup/environment.ts b/uitests/src/setup/environment.ts index cf9c4d12f66c1..c18f82ec1f247 100644 --- a/uitests/src/setup/environment.ts +++ b/uitests/src/setup/environment.ts @@ -120,10 +120,7 @@ async function cloneGitRepo({ url }: { url: string }, cwd: string): Promise)} */ -export async function initializeWorkspace( - scenario: HookScenarioResult, - workspaceFolder: string -): Promise { +export async function initializeWorkspace(scenario: HookScenarioResult, workspaceFolder: string): Promise { const repo = getGitRepo(scenario.pickle.tags); if (!repo) { debug('initializeWorkspace without a repo'); diff --git a/uitests/src/setup/setup.ts b/uitests/src/setup/setup.ts index efd13dea75c2a..d4263ae673951 100644 --- a/uitests/src/setup/setup.ts +++ b/uitests/src/setup/setup.ts @@ -69,16 +69,10 @@ export class TestOptions implements ITestOptions { * @memberof TestOptions */ public async initilize() { - this._workspacePathOrFolder = - this._workspacePathOrFolder || - path.join(this.tempPath, `workspace folder${(TestOptions.workspaceCounter += 1)}`); + this._workspacePathOrFolder = this._workspacePathOrFolder || path.join(this.tempPath, `workspace folder${(TestOptions.workspaceCounter += 1)}`); await Promise.all([ - new Promise(resolve => rimraf(this.tempPath, resolve)).catch( - warn.bind(warn, 'Failed to empty temp dir in updateForScenario') - ), - new Promise(resolve => rimraf(this._workspacePathOrFolder, resolve)).catch( - warn.bind(warn, 'Failed to create workspace directory') - ) + new Promise(resolve => rimraf(this.tempPath, resolve)).catch(warn.bind(warn, 'Failed to empty temp dir in updateForScenario')), + new Promise(resolve => rimraf(this._workspacePathOrFolder, resolve)).catch(warn.bind(warn, 'Failed to create workspace directory')) ]); await Promise.all([ fs.ensureDir(this.tempPath), @@ -106,14 +100,8 @@ export class TestOptions implements ITestOptions { */ public async updateForScenario(scenario: HookScenarioResult) { const location = scenario.pickle.locations[0].line; - this._reportsPath = path.join( - this.rootReportsPath, - `${scenario.pickle.name}:${location}:_${TestOptions.workspaceCounter}`.replace(/[^a-z0-9\-]/gi, '_') - ); - this._workspacePathOrFolder = path.join( - this.tempPath, - `workspace folder${(TestOptions.workspaceCounter += 1)}` - ); + this._reportsPath = path.join(this.rootReportsPath, `${scenario.pickle.name}:${location}:_${TestOptions.workspaceCounter}`.replace(/[^a-z0-9\-]/gi, '_')); + this._workspacePathOrFolder = path.join(this.tempPath, `workspace folder${(TestOptions.workspaceCounter += 1)}`); // await Promise.all([ // fs.ensureDir(scenarioLogsPath), // fs.emptyDir(this.tempPath).catch(warn.bind(warn, 'Failed to empty temp dir in updateForScenario')), @@ -137,12 +125,7 @@ export class TestOptions implements ITestOptions { * @export * @returns {TestOptions} */ -export function getTestOptions( - channel: Channel, - testDir: string, - pythonPath: string = 'python', - verboseLogging: boolean = false -): ITestOptions { +export function getTestOptions(channel: Channel, testDir: string, pythonPath: string = 'python', verboseLogging: boolean = false): ITestOptions { pythonPath = pythonPath || cp @@ -150,13 +133,7 @@ export function getTestOptions( .toString() .trim(); const options = new TestOptions(channel, testDir, path.join(testDir, 'temp folder'), verboseLogging, pythonPath); - [ - options.tempPath, - options.userDataPath, - options.logsPath, - options.screenshotsPath, - options.workspacePathOrFolder - ].forEach(dir => { + [options.tempPath, options.userDataPath, options.logsPath, options.screenshotsPath, options.workspacePathOrFolder].forEach(dir => { try { rimraf.sync(dir); } catch { diff --git a/uitests/src/steps/core.ts b/uitests/src/steps/core.ts index 0045380279e10..ec1828c2e4835 100644 --- a/uitests/src/steps/core.ts +++ b/uitests/src/steps/core.ts @@ -49,9 +49,7 @@ When('I reload VS Code', function() { return this.app.reload(); }); -When('I wait for a maximum of {int} seconds for the Python extension to get activated', async function( - seconds: number -) { +When('I wait for a maximum of {int} seconds for the Python extension to get activated', async function(seconds: number) { await waitForPythonExtensionToActivate(seconds * 1000, this.app); }); diff --git a/uitests/src/steps/debugger.ts b/uitests/src/steps/debugger.ts index 1462f046d4085..69b9b54d44782 100644 --- a/uitests/src/steps/debugger.ts +++ b/uitests/src/steps/debugger.ts @@ -30,10 +30,7 @@ Then('the debugger stops', async function() { Then('the debugger will stop within {int} seconds', async function(timeoutSeconds: number) { await this.app.debugger.waitUntilStopped(timeoutSeconds * 1000); }); -Then('the current stack frame is at line {int} in {string}', CucumberRetryMax5Seconds, async function( - line: number, - fileName: string -) { +Then('the current stack frame is at line {int} in {string}', CucumberRetryMax5Seconds, async function(line: number, fileName: string) { await this.app.documents.waitForActiveEditor(fileName); await this.app.documents.waitForPosition({ line }); }); diff --git a/uitests/src/steps/documents.ts b/uitests/src/steps/documents.ts index 8058f32d2b935..19cfe1e18b8ef 100644 --- a/uitests/src/steps/documents.ts +++ b/uitests/src/steps/documents.ts @@ -35,10 +35,7 @@ When('I create a new file with the following content', async function(contents: await sleep(200); }); -Given('a file named {string} is created with the following content', async function( - filename: string, - contents: string -) { +Given('a file named {string} is created with the following content', async function(filename: string, contents: string) { const fullpath = path.join(this.app.workspacePathOrFolder, filename); await fs.ensureDir(path.dirname(fullpath)); await fs.writeFile(fullpath, contents); diff --git a/uitests/src/steps/main.ts b/uitests/src/steps/main.ts index 187217c5edd18..bb9d005204e50 100644 --- a/uitests/src/steps/main.ts +++ b/uitests/src/steps/main.ts @@ -3,15 +3,7 @@ 'use strict'; -import { - After, - Before, - HookScenarioResult, - setDefaultTimeout, - setDefinitionFunctionWrapper, - setWorldConstructor, - Status -} from 'cucumber'; +import { After, Before, HookScenarioResult, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, Status } from 'cucumber'; import * as fs from 'fs-extra'; import * as path from 'path'; import * as rimraf from 'rimraf'; @@ -44,16 +36,9 @@ class MyWorld { public readonly options: ITestOptions; constructor({ parameters, attach }: { attach: Function; parameters: WorldParameters }) { debug('Start MyWorld contructor'); - const testOptions = getTestOptions( - parameters.channel, - parameters.testDir, - parameters.pythonPath, - parameters.verboseLogging - ); + const testOptions = getTestOptions(parameters.channel, parameters.testDir, parameters.pythonPath, parameters.verboseLogging); this.app = new Application(testOptions); - this.app.on('start', emulateFirstTimeLoad => - emulateFirstTimeLoad ? (oneTimeMessagesDismissed = false) : undefined - ); + this.app.on('start', emulateFirstTimeLoad => (emulateFirstTimeLoad ? (oneTimeMessagesDismissed = false) : undefined)); this.app.on('screenshotCatured', data => attach(data, 'image/png')); this.options = testOptions; debug('End MyWorld contructor'); diff --git a/uitests/src/steps/notifications.ts b/uitests/src/steps/notifications.ts index 1ccc291d85ee4..8a70f16295d33 100644 --- a/uitests/src/steps/notifications.ts +++ b/uitests/src/steps/notifications.ts @@ -44,10 +44,7 @@ Then('a message containing the text {string} is displayed', async function(messa await notificationDisplayed(this.app, message); }); -Then('a message containing the text {string} will be displayed within {int} seconds', async function( - message: string, - timeoutSeconds: number -) { +Then('a message containing the text {string} will be displayed within {int} seconds', async function(message: string, timeoutSeconds: number) { await notificationDisplayed(this.app, message, timeoutSeconds * 1000); }); @@ -76,10 +73,7 @@ Then('a message containing the text {string} is not displayed', async function(m await messageIsNotDisplayed(this.app, message); }); -Then('I click the {string} button for the message with the text {string}', CucumberRetryMax20Seconds, async function( - button: string, - message: string -) { +Then('I click the {string} button for the message with the text {string}', CucumberRetryMax20Seconds, async function(button: string, message: string) { await notificationDisplayed(this.app, message); await this.app.notifications.dismiss([{ buttonText: button, content: message }], 2); // We might have to retry closing the message as its possible a new message was displayed in the mean time. diff --git a/uitests/src/steps/outputPanel.ts b/uitests/src/steps/outputPanel.ts index 6af2ad639fff4..4e787422d397b 100644 --- a/uitests/src/steps/outputPanel.ts +++ b/uitests/src/steps/outputPanel.ts @@ -9,17 +9,10 @@ import { Then } from 'cucumber'; import '../helpers/extensions'; type TextOrWordOrContent = 'text' | 'word' | 'message' | 'content'; -Then('the {word} {string} will be displayed in the output panel', async function( - _textOrMessage: TextOrWordOrContent, - text: string -) { +Then('the {word} {string} will be displayed in the output panel', async function(_textOrMessage: TextOrWordOrContent, text: string) { await this.app.panels.waitUtilContent(text); }); -Then('the {word} {string} will be displayed in the output panel within {int} seconds', async function( - _textOrMessage: TextOrWordOrContent, - text: string, - timeoutSeconds: number -) { +Then('the {word} {string} will be displayed in the output panel within {int} seconds', async function(_textOrMessage: TextOrWordOrContent, text: string, timeoutSeconds: number) { await this.app.panels.waitUtilContent(text, timeoutSeconds); }); diff --git a/uitests/src/steps/problems.ts b/uitests/src/steps/problems.ts index 4d2fe62e813d2..74712384eee00 100644 --- a/uitests/src/steps/problems.ts +++ b/uitests/src/steps/problems.ts @@ -24,9 +24,7 @@ Then('there is at least one problem in the problems panel', CucumberRetryMax5Sec expect(count).to.greaterThan(0); }); -Then('there are at least {int} problems in the problems panel', CucumberRetryMax5Seconds, async function( - expectedMinimumCount: number -) { +Then('there are at least {int} problems in the problems panel', CucumberRetryMax5Seconds, async function(expectedMinimumCount: number) { const count = await this.app.problems.getProblemCount(); expect(count).to.greaterThan(expectedMinimumCount - 1); }); diff --git a/uitests/src/steps/settings.ts b/uitests/src/steps/settings.ts index a71724b85a05c..022cb8d02cffd 100644 --- a/uitests/src/steps/settings.ts +++ b/uitests/src/steps/settings.ts @@ -9,66 +9,37 @@ import * as assert from 'assert'; import { Given, Then, When } from 'cucumber'; import { ConfigurationTarget } from '../types'; -const translateType = (type: SettingType) => - type === 'user' ? ConfigurationTarget.Global : ConfigurationTarget.WorkspaceFolder; +const translateType = (type: SettingType) => (type === 'user' ? ConfigurationTarget.Global : ConfigurationTarget.WorkspaceFolder); type SettingType = 'user' | 'workspaceFolder' | 'workspace'; type EnabledOrDisabled = 'enabled' | 'disabled'; type EnabledOrDisabledOrRemove = 'enable' | 'disable' | 'remove'; -Given('the {word} setting {string} is {word}', async function( - type: SettingType, - setting: string, - enabledOrDisabled: EnabledOrDisabled -) { +Given('the {word} setting {string} is {word}', async function(type: SettingType, setting: string, enabledOrDisabled: EnabledOrDisabled) { await this.app.settings.updateSetting(setting, enabledOrDisabled === 'enabled', translateType(type)); }); -Given('the {word} setting {string} has the value {string}', async function( - type: SettingType, - setting: string, - value: string -) { +Given('the {word} setting {string} has the value {string}', async function(type: SettingType, setting: string, value: string) { await this.app.settings.updateSetting(setting, value, translateType(type)); }); -Given('the {word} setting {string} has the value {int}', async function( - type: SettingType, - setting: string, - value: number -) { +Given('the {word} setting {string} has the value {int}', async function(type: SettingType, setting: string, value: number) { await this.app.settings.updateSetting(setting, value, translateType(type)); }); Given('the {word} setting {string} does not exist', async function(type: SettingType, setting: string) { await this.app.settings.updateSetting(setting, void 0, translateType(type)); }); -When('I {word} the {word} setting {string}', async function( - change: EnabledOrDisabledOrRemove, - type: SettingType, - setting: string -) { +When('I {word} the {word} setting {string}', async function(change: EnabledOrDisabledOrRemove, type: SettingType, setting: string) { const newValue = change === 'remove' ? void 0 : change === 'enable'; await this.app.settings.updateSetting(setting, newValue, translateType(type)); }); -When('I update the {word} setting {string} with the value {string}', async function( - type: SettingType, - setting: string, - value: string -) { +When('I update the {word} setting {string} with the value {string}', async function(type: SettingType, setting: string, value: string) { await this.app.settings.updateSetting(setting, value, translateType(type)); }); -When('I update the {word} setting {string} with the value {int}', async function( - type: SettingType, - setting: string, - value: number -) { +When('I update the {word} setting {string} with the value {int}', async function(type: SettingType, setting: string, value: number) { await this.app.settings.updateSetting(setting, value, translateType(type)); }); -Then('the {word} setting {string} will be {word}', async function( - type: SettingType, - setting: string, - enabledOrDisabled: EnabledOrDisabled -) { +Then('the {word} setting {string} will be {word}', async function(type: SettingType, setting: string, enabledOrDisabled: EnabledOrDisabled) { const value = await this.app.settings.getSetting(setting, translateType(type)); assert.equal(value, enabledOrDisabled === 'enabled'); }); @@ -84,10 +55,7 @@ Then('the workspace setting {string} has the value {int}', async function(settin const value = await this.app.settings.getSetting(setting, ConfigurationTarget.WorkspaceFolder); assert.equal(value, expectedValue); }); -Then('the workspace setting {string} contains the value {string}', async function( - setting: string, - expectedValue: string -) { +Then('the workspace setting {string} contains the value {string}', async function(setting: string, expectedValue: string) { const value = await this.app.settings.getSetting(setting, ConfigurationTarget.WorkspaceFolder); assert.notEqual(value, undefined); assert.equal(value!.indexOf(expectedValue) >= 0, expectedValue); diff --git a/uitests/src/steps/statusbar.ts b/uitests/src/steps/statusbar.ts index 26884edcc4587..7cf625213bcdb 100644 --- a/uitests/src/steps/statusbar.ts +++ b/uitests/src/steps/statusbar.ts @@ -17,9 +17,7 @@ Then('the python the status bar contains the text {string}', CucumberRetryMax5Se }); // Add a delay, as this can take around 1s (from the time something was selected). -Then('the python the status bar does not contain the text {string}', CucumberRetryMax5Seconds, async function( - text: string -) { +Then('the python the status bar does not contain the text {string}', CucumberRetryMax5Seconds, async function(text: string) { const statubarText = await this.app.statusbar.getPythonStatusBarText(); expect(statubarText).not.contains(text); }); diff --git a/uitests/src/steps/testing.ts b/uitests/src/steps/testing.ts index 89ca866749ded..df142f06ebc92 100644 --- a/uitests/src/steps/testing.ts +++ b/uitests/src/steps/testing.ts @@ -37,23 +37,15 @@ async function getNumberOfNodesWithIcon(app: IApplication, status: TestExplorerN const elements = await app.testExplorer.getNodes(); return elements.filter(node => node.status === status).length; } -Then('{int} nodes in the test explorer have a status of "{word}"', CucumberRetryMax5Seconds, async function( - count: number, - status: TestExplorerNodeStatus -) { +Then('{int} nodes in the test explorer have a status of "{word}"', CucumberRetryMax5Seconds, async function(count: number, status: TestExplorerNodeStatus) { const nodeCount = await getNumberOfNodesWithIcon(this.app, status); expect(nodeCount).to.equal(count); }); -Then('1 node in the test explorer has a status of "{word}"', CucumberRetryMax5Seconds, async function( - status: TestExplorerNodeStatus -) { +Then('1 node in the test explorer has a status of "{word}"', CucumberRetryMax5Seconds, async function(status: TestExplorerNodeStatus) { const nodeCount = await getNumberOfNodesWithIcon(this.app, status); expect(nodeCount).to.equal(1); }); -Then('the node {string} in the test explorer has a status of "{word}"', CucumberRetryMax5Seconds, async function( - label: string, - status: TestExplorerNodeStatus -) { +Then('the node {string} in the test explorer has a status of "{word}"', CucumberRetryMax5Seconds, async function(label: string, status: TestExplorerNodeStatus) { const node = await this.app.testExplorer.getNode(label); expect(node.status).to.equal(status); }); diff --git a/uitests/src/testRunner.ts b/uitests/src/testRunner.ts index 065a435af1634..d1d0b8ea6cef0 100644 --- a/uitests/src/testRunner.ts +++ b/uitests/src/testRunner.ts @@ -61,12 +61,7 @@ async function parseCucumberJson(jsonFile: string): Promise { function hasScenarioPassed(scenario: Scenario): boolean { return scenario.steps.every(step => step.result.status === 'passed'); } -async function findScenario( - report: CucumberReport, - featureId: string, - scenarioId: string, - line: number -): Promise { +async function findScenario(report: CucumberReport, featureId: string, scenarioId: string, line: number): Promise { for (const feature of report) { if (feature.id !== featureId) { continue; @@ -76,9 +71,7 @@ async function findScenario( return found; } } - throw new Error( - `Feature & Scenario not found. FeatureId = ${featureId}, ScenarioId = ${scenarioId}, line = ${line}` - ); + throw new Error(`Feature & Scenario not found. FeatureId = ${featureId}, ScenarioId = ${scenarioId}, line = ${line}`); } async function getCucumberResultStats(json: CucumberReport): Promise { @@ -111,13 +104,7 @@ async function shouldRerunTests(results: CucumberResults): Promise { return false; } -export async function start( - channel: Channel, - testDir: string, - verboseLogging: boolean, - pythonPath: string, - cucumberArgs: string[] -) { +export async function start(channel: Channel, testDir: string, verboseLogging: boolean, pythonPath: string, cucumberArgs: string[]) { const options = getTestOptions(channel, testDir, pythonPath, verboseLogging); await initialize(options); await fs.ensureDir(options.reportsPath); @@ -144,12 +131,7 @@ export async function start( for (const feature of rerurnJson) { for (const scenario of feature.elements) { if (hasScenarioPassed(scenario)) { - const originalScenario = await findScenario( - originalJson, - feature.id, - scenario.id, - scenario.line - ); + const originalScenario = await findScenario(originalJson, feature.id, scenario.id, scenario.line); Object.keys(scenario).forEach(key => { // tslint:disable-next-line: no-any (originalScenario as any)[key] = (scenario as any)[key]; @@ -195,10 +177,7 @@ export async function start( // Generate necessary reports. const jsonReportFilePath = results.jsonReportFile; await addReportMetadata(options, jsonReportFilePath); - await Promise.all([ - generateHtmlReport(options, jsonReportFilePath), - generateJUnitReport(options, jsonReportFilePath) - ]); + await Promise.all([generateHtmlReport(options, jsonReportFilePath), generateJUnitReport(options, jsonReportFilePath)]); // Bye bye. if (!success) { @@ -206,17 +185,8 @@ export async function start( } } -async function runCucumber( - cucumberArgs: string[], - worldParameters: WorldParameters, - rerunFile?: string -): Promise { - const jsonReportFile = path.join( - uitestsRootPath, - '.vscode test', - 'reports', - `cucumber_report_${new Date().getTime()}.json` - ); +async function runCucumber(cucumberArgs: string[], worldParameters: WorldParameters, rerunFile?: string): Promise { + const jsonReportFile = path.join(uitestsRootPath, '.vscode test', 'reports', `cucumber_report_${new Date().getTime()}.json`); const newRerunFile = `@rerun${new Date().getTime()}.txt`; const args: string[] = [ '', // Leave empty (not used by cucmberjs) diff --git a/uitests/src/types.ts b/uitests/src/types.ts index 4e36aa3987db5..0c3432495ca4d 100644 --- a/uitests/src/types.ts +++ b/uitests/src/types.ts @@ -241,10 +241,7 @@ export interface IDriver { * @returns {Promise} * @memberof IDriver */ - $$( - selector: string, - options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate } - ): Promise; + $$(selector: string, options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate }): Promise; /** * This method runs `document.querySelector` within the context and passes it as the first argument to `pageFunction`. * If there's no element matching `selector`, the method throws an error. @@ -268,11 +265,7 @@ export interface IDriver { * @param x1 First argument to pass to pageFunction * @returns Promise which resolves to the return value of pageFunction */ - $eval( - selector: string, - pageFunction: (element: Element, x1: UnwrapElementHandle) => R | Promise, - x1: X1 - ): Promise>; + $eval(selector: string, pageFunction: (element: Element, x1: UnwrapElementHandle) => R | Promise, x1: X1): Promise>; /** * This method runs `Array.from(document.querySelectorAll(selector))` within the context and passes it as the @@ -296,11 +289,7 @@ export interface IDriver { * @param x1 First argument to pass to pageFunction * @returns Promise which resolves to the return value of pageFunction */ - $$eval( - selector: string, - pageFunction: (elements: Element[], x1: UnwrapElementHandle) => R | Promise, - x1: X1 - ): Promise>; + $$eval(selector: string, pageFunction: (elements: Element[], x1: UnwrapElementHandle) => R | Promise, x1: X1): Promise>; /** * This method fetches an element with selector, scrolls it into view if needed, and diff --git a/uitests/src/vscode/application.ts b/uitests/src/vscode/application.ts index 4c017ac09eebf..b2630ce1b1e63 100644 --- a/uitests/src/vscode/application.ts +++ b/uitests/src/vscode/application.ts @@ -100,9 +100,7 @@ export class Application extends EventEmitter implements IApplication { // Also delete the downloaded language server. await Promise.all([ new Promise(resolve => rimraf(this.options.userDataPath, resolve)), - new Promise(resolve => - rimraf(path.join(this.options.extensionsPath, '**', 'languageServer.*'), resolve) - ) + new Promise(resolve => rimraf(path.join(this.options.extensionsPath, '**', 'languageServer.*'), resolve)) ]); // These must never change (we control the test environment). diff --git a/uitests/src/vscode/debugger.ts b/uitests/src/vscode/debugger.ts index b12918d5c2471..accf115b2aafe 100644 --- a/uitests/src/vscode/debugger.ts +++ b/uitests/src/vscode/debugger.ts @@ -53,8 +53,7 @@ export class Debugger implements IDebugger { @retry(RetryMax10Seconds) public async waitUntilPaused(): Promise { const iconSelector = this.app.getCSSSelector(Selector.DebugToolbarIcon); - const predicateToFindTitleWithContinue = (elements: Element[]) => - elements.find(element => (element.getAttribute('title') || '').includes('Continue')) !== undefined; + const predicateToFindTitleWithContinue = (elements: Element[]) => elements.find(element => (element.getAttribute('title') || '').includes('Continue')) !== undefined; const found = await this.app.driver.$$eval(iconSelector, predicateToFindTitleWithContinue); ok(found); } diff --git a/uitests/src/vscode/documents.ts b/uitests/src/vscode/documents.ts index 80a07285e4439..aeaf664e81e62 100644 --- a/uitests/src/vscode/documents.ts +++ b/uitests/src/vscode/documents.ts @@ -66,9 +66,7 @@ export class Documents implements IDocuments { await this.app.quickopen.runCommand(commandToRunAfterRefreshingExplorer); } } - public async gotToPosition( - options: { line: number } | { column: number } | { line: number; column: number } - ): Promise { + public async gotToPosition(options: { line: number } | { column: number } | { line: number; column: number }): Promise { if ('line' in options) { await this.goToLine(options.line); } @@ -86,9 +84,7 @@ export class Documents implements IDocuments { } public getAutoCompletionList(): Promise { const selector = this.app.getCSSSelector(Selector.AutoCompletionListItem); - return this.app.driver - .$$eval(selector, elements => elements.map(element => element.textContent || '')) - .then(items => items.map(item => item.normalize())); + return this.app.driver.$$eval(selector, elements => elements.map(element => element.textContent || '')).then(items => items.map(item => item.normalize())); } public async waitForEditorFocus(fileName: string): Promise { await this.waitForActiveTab(fileName); @@ -99,9 +95,7 @@ export class Documents implements IDocuments { await this.app.driver.waitForSelector(selector, { timeout: 5000, visible: true }); } public async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise { - const selector = `.tabs-container div.tab.active${ - isDirty ? '.dirty' : '' - }[aria-selected="true"][aria-label="${fileName}, tab"]`; + const selector = `.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName}, tab"]`; await this.app.driver.waitForSelector(selector, { timeout: 5000, visible: true }); } private async gotToColumn(columnNumber: number): Promise { diff --git a/uitests/src/vscode/notifications.ts b/uitests/src/vscode/notifications.ts index 7791353286ffa..9dd91a5135e80 100644 --- a/uitests/src/vscode/notifications.ts +++ b/uitests/src/vscode/notifications.ts @@ -31,10 +31,7 @@ export class Notifications implements INotifications { * @returns {Promise} * @memberof Notifications */ - public async dismiss( - messages: { content: string; buttonText?: string | undefined }[], - timeout: number - ): Promise { + public async dismiss(messages: { content: string; buttonText?: string | undefined }[], timeout: number): Promise { const stopwatch = new StopWatch(); const _closeNotifications = async (): Promise => { if (messages.length === 0) { @@ -50,9 +47,7 @@ export class Notifications implements INotifications { // Check if we can find a notification with this message. const selector = this.app.getCSSSelector(Selector.NthNotificationMessage).format((i + 1).toString()); const textContent = await this.app.driver - .$$eval(selector, elements => - elements.reduce((content, element) => element.textContent || content, '') - ) + .$$eval(selector, elements => elements.reduce((content, element) => element.textContent || content, '')) .catch(warn.bind(warn, `Failed to get content of notification with selector '${selector}'`)); if (!textContent) { @@ -68,9 +63,7 @@ export class Notifications implements INotifications { } const closeSelector = message.buttonText - ? this.app - .getCSSSelector(Selector.ButtonInNthNotification) - .format((i + 1).toString(), message.buttonText) + ? this.app.getCSSSelector(Selector.ButtonInNthNotification).format((i + 1).toString(), message.buttonText) : this.app.getCSSSelector(Selector.CloseButtonInNthNotification).format((i + 1).toString()); // If we found a notification with this message, then use the selector to dismiss it. diff --git a/uitests/src/vscode/quickOpen.ts b/uitests/src/vscode/quickOpen.ts index 38377045594b7..08baf73610328 100644 --- a/uitests/src/vscode/quickOpen.ts +++ b/uitests/src/vscode/quickOpen.ts @@ -62,9 +62,7 @@ export class QuickOpen extends EventEmitter implements IQuickOpen { await this.app.driver.waitForSelector(this.app.getCSSSelector(Selector.QuickOpenInput)); } public async waitUntilClosed(): Promise { - await this.app.driver - .waitForSelector(this.app.getCSSSelector(Selector.QuickOpenInput), { hidden: true }) - .catch(warn.bind(warn, 'Quick Open not hidden')); + await this.app.driver.waitForSelector(this.app.getCSSSelector(Selector.QuickOpenInput), { hidden: true }).catch(warn.bind(warn, 'Quick Open not hidden')); } @retry(RetryMax30Seconds) private async _runCommand(command: string): Promise { @@ -115,33 +113,17 @@ export class QuickOpen extends EventEmitter implements IQuickOpen { // For some reason VSC seems to display the item in the quick open in a funky way. // If we retry it will work, but why waste cpu cycles, lets accomodate for this funky state. const [highlightedItems, highlightedItem2s] = await Promise.all([ - this.app.driver.$$eval(this.app.getCSSSelector(Selector.QuickOpenEntryLabelFocused), elements => - elements.map(e => (e.textContent || '').toLowerCase()) - ), - this.app.driver.$$eval(this.app.getCSSSelector(Selector.QuickOpenEntryLabelFocused2), elements => - elements.map(e => (e.textContent || '').toLowerCase()) - ) + this.app.driver.$$eval(this.app.getCSSSelector(Selector.QuickOpenEntryLabelFocused), elements => elements.map(e => (e.textContent || '').toLowerCase())), + this.app.driver.$$eval(this.app.getCSSSelector(Selector.QuickOpenEntryLabelFocused2), elements => elements.map(e => (e.textContent || '').toLowerCase())) ]); - if ( - Array.isArray(highlightedItems) && - highlightedItems.length > 0 && - (highlightedItems[0] || '').normalize() === value - ) { + if (Array.isArray(highlightedItems) && highlightedItems.length > 0 && (highlightedItems[0] || '').normalize() === value) { debug(' - Command highlighted in quick open'); return; } - if ( - Array.isArray(highlightedItem2s) && - highlightedItem2s.length > 0 && - (highlightedItem2s[0] || '').normalize() === value - ) { + if (Array.isArray(highlightedItem2s) && highlightedItem2s.length > 0 && (highlightedItem2s[0] || '').normalize() === value) { debug(' - Command highlighted in quick open'); return; } - throw new Error( - `Item '${value}' not found in quick open, lets wait for some more time. Items found ${highlightedItems.join( - ', ' - )} & ${highlightedItem2s.join(', ')}.` - ); + throw new Error(`Item '${value}' not found in quick open, lets wait for some more time. Items found ${highlightedItems.join(', ')} & ${highlightedItem2s.join(', ')}.`); } } diff --git a/uitests/src/vscode/settings.ts b/uitests/src/vscode/settings.ts index 06d589e9e33f5..8fd1b3abf7353 100644 --- a/uitests/src/vscode/settings.ts +++ b/uitests/src/vscode/settings.ts @@ -39,11 +39,7 @@ export class Settings implements ISettings { await this.saveSettingsContent(applyEdits(content, edits), scope); } } - public async updateSetting( - setting: string, - value: string | boolean | number | void, - scope: ConfigurationTarget - ): Promise { + public async updateSetting(setting: string, value: string | boolean | number | void, scope: ConfigurationTarget): Promise { let content = await this.getSettingsContent(scope); if (!content) { content = '{}'; @@ -101,10 +97,7 @@ export class Settings implements ISettings { } private async getSettingsContent(scope: ConfigurationTarget): Promise { - const jsonFile = - scope === ConfigurationTarget.Global - ? this.app.userSettingsFilePath - : path.join(this.app.workspacePathOrFolder, '.vscode', 'settings.json'); + const jsonFile = scope === ConfigurationTarget.Global ? this.app.userSettingsFilePath : path.join(this.app.workspacePathOrFolder, '.vscode', 'settings.json'); if (!(await fs.pathExists(jsonFile))) { return; } @@ -112,10 +105,7 @@ export class Settings implements ISettings { } private async saveSettingsContent(content: string, scope: ConfigurationTarget): Promise { - const jsonFile = - scope === ConfigurationTarget.Global - ? this.app.userSettingsFilePath - : path.join(this.app.workspacePathOrFolder, '.vscode', 'settings.json'); + const jsonFile = scope === ConfigurationTarget.Global ? this.app.userSettingsFilePath : path.join(this.app.workspacePathOrFolder, '.vscode', 'settings.json'); await fs.mkdirp(path.dirname(jsonFile)).catch(noop); return fs.writeFile(jsonFile, content, 'utf8'); } diff --git a/uitests/src/vscode/testExplorer.ts b/uitests/src/vscode/testExplorer.ts index be2e4b3cd5998..45206df89cd6a 100644 --- a/uitests/src/vscode/testExplorer.ts +++ b/uitests/src/vscode/testExplorer.ts @@ -61,10 +61,7 @@ export class TestExplorer implements ITestExplorer { }); } public async waitUntilTestsStop(timeout: number): Promise { - await this.app.driver.waitForSelector( - this.app.getCSSSelector(Selector.TestExplorerToolbarcon).format(iconTitleMapping.Stop), - { timeout, hidden: true } - ); + await this.app.driver.waitForSelector(this.app.getCSSSelector(Selector.TestExplorerToolbarcon).format(iconTitleMapping.Stop), { timeout, hidden: true }); } public async expandNodes(maxNodes: number = maxNodesToExpand): Promise { await this.ensureOpened(); @@ -245,9 +242,7 @@ export class TestExplorer implements ITestExplorer { await sleep(delayForUIToUpdate); } } - private async getNodeInfo( - options: { label: string } | { nodeNumber: number } | { label: string; nodeNumber: number } - ): Promise { + private async getNodeInfo(options: { label: string } | { nodeNumber: number } | { label: string; nodeNumber: number }): Promise { let label = ''; let nodeNumber = -1; if ('nodeNumber' in options) { @@ -269,15 +264,12 @@ export class TestExplorer implements ITestExplorer { this.app.driver.$eval(selector, element => element.className) ]); - const status = Array.from(statusToIconMapping.entries()).reduce( - (currentStatus, item) => { - if (bgIcon.includes(item[1])) { - return item[0]; - } - return currentStatus; - }, - 'Unknown' - ); + const status = Array.from(statusToIconMapping.entries()).reduce((currentStatus, item) => { + if (bgIcon.includes(item[1])) { + return item[0]; + } + return currentStatus; + }, 'Unknown'); return { expanded: className.indexOf('expanded') >= 0,