diff --git a/test/automation/src/code.ts b/test/automation/src/code.ts index e8ad52540b5..1647e78640b 100644 --- a/test/automation/src/code.ts +++ b/test/automation/src/code.ts @@ -185,7 +185,7 @@ export class Code { try { process.kill(pid, 0); // throws an exception if the process doesn't exist anymore. - await new Promise(resolve => setTimeout(resolve, 500)); + await this.wait(500); } catch (error) { done = true; resolve(); @@ -254,6 +254,10 @@ export class Code { return this.driver.getLogs(); } + wait(millis: number): Promise { + return this.driver.wait(millis); + } + private async poll( fn: () => Promise, acceptFn: (result: T) => boolean, @@ -285,7 +289,7 @@ export class Code { lastError = Array.isArray(e.stack) ? e.stack.join(os.EOL) : e.stack; } - await new Promise(resolve => setTimeout(resolve, retryInterval)); + await this.wait(retryInterval); trial++; } } diff --git a/test/automation/src/playwrightDriver.ts b/test/automation/src/playwrightDriver.ts index 1b63f622f4e..ddc99579fdf 100644 --- a/test/automation/src/playwrightDriver.ts +++ b/test/automation/src/playwrightDriver.ts @@ -157,7 +157,7 @@ export class PlaywrightDriver { for (let i = 0; i < chords.length; i++) { const chord = chords[i]; if (i > 0) { - await this.timeout(100); + await this.wait(100); } if (keybinding.startsWith('Alt') || keybinding.startsWith('Control') || keybinding.startsWith('Backspace')) { @@ -179,7 +179,7 @@ export class PlaywrightDriver { } } - await this.timeout(100); + await this.wait(100); } async click(selector: string, xoffset?: number | undefined, yoffset?: number | undefined) { @@ -235,7 +235,7 @@ export class PlaywrightDriver { return this.page.evaluate(pageFunction, [await this.getDriverHandle()]); } - private timeout(ms: number): Promise { + wait(ms: number): Promise { return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/test/automation/src/quickaccess.ts b/test/automation/src/quickaccess.ts index 116f58b7747..4c0f1079db1 100644 --- a/test/automation/src/quickaccess.ts +++ b/test/automation/src/quickaccess.ts @@ -171,15 +171,33 @@ export class QuickAccess { } async runCommand(commandId: string, keepOpen?: boolean): Promise { + let retries = 0; - // open commands picker - await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`); + while (++retries < 5) { - // wait for best choice to be focused - await this.quickInput.waitForQuickInputElementFocused(); + // open commands picker + await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`); + + // wait for best choice to be focused + await this.quickInput.waitForQuickInputElementFocused(); + + // Retry for as long as the command not found + const text = await this.quickInput.waitForQuickInputElementText(); + if (text === 'No matching commands') { + this.code.logger.log(`QuickAccess: No matching commands, will retry...`); + await this.quickInput.closeQuickInput(); + await this.code.wait(1000); + continue; + } + + // wait and click on best choice + await this.quickInput.selectQuickInputElement(0, keepOpen); + + return; + } + + throw new Error(`Command: ${commandId} Not found`); - // wait and click on best choice - await this.quickInput.selectQuickInputElement(0, keepOpen); } async openQuickOutline(): Promise { diff --git a/test/automation/src/terminal.ts b/test/automation/src/terminal.ts index 56b6f46ddb4..e0604a5b45f 100644 --- a/test/automation/src/terminal.ts +++ b/test/automation/src/terminal.ts @@ -99,7 +99,7 @@ export class Terminal { // after 2 seconds. await Promise.race([ this.code.waitForElements(Selector.Xterm, true, e => e.length === 0), - new Promise(r => setTimeout(r, 2000)) + this.code.wait(2000) ]); break; } diff --git a/test/smoke/src/areas/extensions/extensions.test.ts b/test/smoke/src/areas/extensions/extensions.test.ts index bc65a8631c4..c78cbe87089 100644 --- a/test/smoke/src/areas/extensions/extensions.test.ts +++ b/test/smoke/src/areas/extensions/extensions.test.ts @@ -7,7 +7,7 @@ import { Application, Logger } from '../../../../automation'; import { installAllHandlers } from '../../utils'; export function setup(logger: Logger) { - describe.skip('Extensions', () => { + describe('Extensions', () => { // Shared before/after handling installAllHandlers(logger); diff --git a/test/smoke/src/areas/workbench/localization.test.ts b/test/smoke/src/areas/workbench/localization.test.ts index 865add9ae79..12e49ce549e 100644 --- a/test/smoke/src/areas/workbench/localization.test.ts +++ b/test/smoke/src/areas/workbench/localization.test.ts @@ -8,7 +8,7 @@ import { installAllHandlers } from '../../utils'; export function setup(logger: Logger) { - describe.skip('Localization', () => { + describe('Localization', () => { // Shared before/after handling installAllHandlers(logger);