From e3a05e01869b76e552e83c4aa0b0e8dc2c4e1ae8 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Sep 2017 10:41:58 +0200 Subject: [PATCH] smoke: wait for marketplace for longer than 5 seconds --- test/smoke/src/areas/extensions/extensions.ts | 6 +++++- test/smoke/src/spectron/client.ts | 9 +++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/smoke/src/areas/extensions/extensions.ts b/test/smoke/src/areas/extensions/extensions.ts index 85e31128658..af4fdbb47a0 100644 --- a/test/smoke/src/areas/extensions/extensions.ts +++ b/test/smoke/src/areas/extensions/extensions.ts @@ -33,7 +33,11 @@ export class Extensions extends Viewlet { public async installExtension(name: string): Promise { await this.searchForExtension(name); - await this.spectron.client.waitAndClick(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.install`); + + // we might want to wait for a while longer since the Marketplace can be slow + // a minute should do + await this.spectron.client.waitFor(() => this.spectron.client.click(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.install`), void 0, 'waiting for install button', 600); + await this.spectron.client.waitForElement(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.reload`); return true; } diff --git a/test/smoke/src/spectron/client.ts b/test/smoke/src/spectron/client.ts index ddc67fb7a1e..e04cdd7b73a 100644 --- a/test/smoke/src/spectron/client.ts +++ b/test/smoke/src/spectron/client.ts @@ -145,14 +145,15 @@ export class SpectronClient { return this.spectron.client.getTitle(); } - public async waitFor(func: () => T | Promise, accept?: (result: T) => boolean | Promise, timeoutMessage?: string): Promise; - public async waitFor(func: () => T | Promise, accept: (result: T) => boolean | Promise = result => !!result, timeoutMessage?: string): Promise { + public async waitFor(func: () => T | Promise, accept?: (result: T) => boolean | Promise, timeoutMessage?: string, retryCount?: number): Promise; + public async waitFor(func: () => T | Promise, accept: (result: T) => boolean | Promise = result => !!result, timeoutMessage?: string, retryCount?: number): Promise { let trial = 1; + retryCount = typeof retryCount === 'number' ? retryCount : this.retryCount; while (true) { - if (trial > this.retryCount) { + if (trial > retryCount) { this.application.screenCapturer.capture('timeout'); - throw new Error(`${timeoutMessage}: Timed out after ${(this.retryCount * this.retryDuration) / 1000} seconds.`); + throw new Error(`${timeoutMessage}: Timed out after ${(retryCount * this.retryDuration) / 1000} seconds.`); } let result;