From bb39ae82cfdea744117aca693691a5ec13390036 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 20 Dec 2021 08:25:08 +0100 Subject: [PATCH] smoke - improve `runCommand` and disable more tests --- .../notebook.editor.test.ts | 4 +- .../test/node/nativeModules.test.ts | 3 +- test/automation/src/quickaccess.ts | 61 +++++++++---------- test/smoke/src/areas/search/search.test.ts | 2 +- .../src/areas/terminal/terminal-input.test.ts | 3 +- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts index 8465c3ceaaf3e..8b2a1f2459b97 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts @@ -44,7 +44,7 @@ suite('Notebook Editor', function () { testDisposables.length = 0; }); - test('showNotebookDocment', async function () { + test.skip('showNotebookDocument', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139078 const notebookDocumentsFromOnDidOpen = new Set(); const sub = vscode.workspace.onDidOpenNotebookDocument(e => { @@ -86,7 +86,7 @@ suite('Notebook Editor', function () { assert.strictEqual(editor.document.uri.toString(), resource.toString()); }); - test('Active/Visible Editor', async function () { + test.skip('Active/Visible Editor', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/139078 const firstEditorOpen = utils.asPromise(vscode.window.onDidChangeActiveNotebookEditor); const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest'); const firstEditor = await vscode.window.showNotebookDocument(resource); diff --git a/src/vs/platform/environment/test/node/nativeModules.test.ts b/src/vs/platform/environment/test/node/nativeModules.test.ts index f1379a6ff6ffe..7f154f11b5a4c 100644 --- a/src/vs/platform/environment/test/node/nativeModules.test.ts +++ b/src/vs/platform/environment/test/node/nativeModules.test.ts @@ -5,12 +5,13 @@ import * as assert from 'assert'; import { isLinux, isWindows } from 'vs/base/common/platform'; +import { flakySuite } from 'vs/base/test/common/testUtils'; function testErrorMessage(module: string): string { return `Unable to load "${module}" dependency. It was probably not compiled for the right operating system architecture or had missing build tools.`; } -suite('Native Modules (all platforms)', () => { +flakySuite('Native Modules (all platforms)', () => { test('native-is-elevated', async () => { const isElevated = await import('native-is-elevated'); diff --git a/test/automation/src/quickaccess.ts b/test/automation/src/quickaccess.ts index 616e2e6b0d91f..116f58b7747f6 100644 --- a/test/automation/src/quickaccess.ts +++ b/test/automation/src/quickaccess.ts @@ -8,6 +8,12 @@ import { Code } from './code'; import { QuickInput } from './quickinput'; import { basename, isAbsolute } from 'path'; +enum QuickAccessKind { + Files = 1, + Commands, + Symbols +} + export class QuickAccess { constructor(private code: Code, private editors: Editors, private quickInput: QuickInput) { } @@ -30,7 +36,7 @@ export class QuickAccess { let retry = false; try { - await this.openFileQuickAccess(searchValue); + await this.openQuickAccessWithRetry(QuickAccessKind.Files, searchValue); await this.quickInput.waitForQuickInputElements(elementNames => { this.code.logger.log('QuickAccess: resulting elements: ', elementNames); @@ -125,36 +131,49 @@ export class QuickAccess { await this.editors.selectTab(fileName); } - private async openFileQuickAccess(value: string): Promise { + private async openQuickAccessWithRetry(kind: QuickAccessKind, value?: string): Promise { let retries = 0; - // other parts of code might steal focus away from quickinput :( + // Other parts of code might steal focus away from quickinput :( while (retries < 5) { - if (process.platform === 'darwin') { - await this.code.dispatchKeybinding('cmd+p'); - } else { - await this.code.dispatchKeybinding('ctrl+p'); + + // Open via keybinding + switch (kind) { + case QuickAccessKind.Files: + await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+p' : 'ctrl+p'); + break; + case QuickAccessKind.Symbols: + await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+o' : 'ctrl+shift+o'); + break; + case QuickAccessKind.Commands: + await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+p' : 'ctrl+shift+p'); + break; } + // Await for quick input widget opened try { await this.quickInput.waitForQuickInputOpened(10); break; } catch (err) { if (++retries > 5) { - throw err; + throw new Error(`QuickAccess.openQuickAccessWithRetry(kind: ${kind}) failed: ${err}`); } + // Retry await this.code.dispatchKeybinding('escape'); } } - await this.quickInput.type(value); + // Type value if any + if (value) { + await this.quickInput.type(value); + } } async runCommand(commandId: string, keepOpen?: boolean): Promise { // open commands picker - await this.openCommands(`>${commandId}`); + await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`); // wait for best choice to be focused await this.quickInput.waitForQuickInputElementFocused(); @@ -163,33 +182,13 @@ export class QuickAccess { await this.quickInput.selectQuickInputElement(0, keepOpen); } - private async openCommands(value: string): Promise { - - // open commands via keybinding - if (process.platform === 'darwin') { - await this.code.dispatchKeybinding('cmd+shift+p'); - } else { - await this.code.dispatchKeybinding('ctrl+shift+p'); - } - - // wait for commands - await this.quickInput.waitForQuickInputElementFocused(); - - // narrow down to provided value - await this.quickInput.type(value); - } - async openQuickOutline(): Promise { let retries = 0; while (++retries < 10) { // open quick outline via keybinding - if (process.platform === 'darwin') { - await this.code.dispatchKeybinding('cmd+shift+o'); - } else { - await this.code.dispatchKeybinding('ctrl+shift+o'); - } + await this.openQuickAccessWithRetry(QuickAccessKind.Symbols); const text = await this.quickInput.waitForQuickInputElementText(); diff --git a/test/smoke/src/areas/search/search.test.ts b/test/smoke/src/areas/search/search.test.ts index e3f12408988ed..c6db8699c766a 100644 --- a/test/smoke/src/areas/search/search.test.ts +++ b/test/smoke/src/areas/search/search.test.ts @@ -55,7 +55,7 @@ export function setup(logger: Logger) { await app.workbench.search.removeFileMatch('app.js', '12 results in 4 files'); }); - it('replaces first search result with a replace term', async function () { + it.skip('replaces first search result with a replace term', async function () { // TODo@roblourens https://github.com/microsoft/vscode/issues/137195 const app = this.app as Application; await app.workbench.search.searchFor('body'); diff --git a/test/smoke/src/areas/terminal/terminal-input.test.ts b/test/smoke/src/areas/terminal/terminal-input.test.ts index c7e3d41c316ca..26fdd66f10adb 100644 --- a/test/smoke/src/areas/terminal/terminal-input.test.ts +++ b/test/smoke/src/areas/terminal/terminal-input.test.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Application, Terminal, SettingsEditor } from '../../../../automation'; +import { itSkipOnFail } from '../../utils'; export function setup() { describe('Terminal Input', () => { @@ -24,7 +25,7 @@ export function setup() { await terminal.runCommandInTerminal(`"\r${text}`, true); } - it('should automatically reply to default "Terminate batch job (Y/N)"', async () => { + itSkipOnFail('should automatically reply to default "Terminate batch job (Y/N)"', async () => { // TODO@daniel https://github.com/microsoft/vscode/issues/139076 await terminal.createTerminal(); await writeTextForAutoReply('Terminate batch job (Y/N)?'); await terminal.waitForTerminalText(buffer => buffer.some(line => line.match(/\?.*Y/)));