smoke: wait for marketplace for longer than 5 seconds

This commit is contained in:
Joao Moreno
2017-09-15 10:41:58 +02:00
parent d23dce6a7c
commit e3a05e0186
2 changed files with 10 additions and 5 deletions
@@ -33,7 +33,11 @@ export class Extensions extends Viewlet {
public async installExtension(name: string): Promise<boolean> {
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;
}
+5 -4
View File
@@ -145,14 +145,15 @@ export class SpectronClient {
return this.spectron.client.getTitle();
}
public async waitFor<T>(func: () => T | Promise<T | undefined>, accept?: (result: T) => boolean | Promise<boolean>, timeoutMessage?: string): Promise<T>;
public async waitFor<T>(func: () => T | Promise<T>, accept: (result: T) => boolean | Promise<boolean> = result => !!result, timeoutMessage?: string): Promise<T> {
public async waitFor<T>(func: () => T | Promise<T | undefined>, accept?: (result: T) => boolean | Promise<boolean>, timeoutMessage?: string, retryCount?: number): Promise<T>;
public async waitFor<T>(func: () => T | Promise<T>, accept: (result: T) => boolean | Promise<boolean> = result => !!result, timeoutMessage?: string, retryCount?: number): Promise<T> {
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;