From 78d7d64c5d16b8d89d1dd2b0cc7fcbe966feb48b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 6 Jun 2018 11:23:31 +0200 Subject: [PATCH] smoketest: more search assertions --- test/smoke/src/areas/search/search.ts | 30 +++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test/smoke/src/areas/search/search.ts b/test/smoke/src/areas/search/search.ts index 944bb48a49c..9238eeed6e6 100644 --- a/test/smoke/src/areas/search/search.ts +++ b/test/smoke/src/areas/search/search.ts @@ -11,6 +11,22 @@ const INPUT = `${VIEWLET} .search-widget .search-container .monaco-inputbox inpu const INCLUDE_INPUT = `${VIEWLET} .query-details .file-types.includes .monaco-inputbox input`; const FILE_MATCH = filename => `${VIEWLET} .results .filematch[data-resource$="${filename}"]`; +async function retry(setup: () => Promise, attempt: () => Promise) { + let count = 0; + while (true) { + await setup(); + + try { + await attempt(); + return; + } catch (err) { + if (++count > 5) { + throw err; + } + } + } +} + export class Search extends Viewlet { constructor(code: Code) { @@ -56,8 +72,11 @@ export class Search extends Viewlet { async removeFileMatch(filename: string): Promise { const fileMatch = FILE_MATCH(filename); - await this.code.waitAndClick(fileMatch); - await this.code.waitForElement(`${fileMatch} .action-label.icon.action-remove`, el => !!el && el.top > 0 && el.left > 0); + await retry( + () => this.code.waitAndClick(fileMatch), + () => this.code.waitForElement(`${fileMatch} .action-label.icon.action-remove`, el => !!el && el.top > 0 && el.left > 0, 10) + ); + await this.code.waitAndClick(`${fileMatch} .action-label.icon.action-remove`); await this.code.waitForElement(fileMatch, el => !el); } @@ -77,8 +96,11 @@ export class Search extends Viewlet { async replaceFileMatch(filename: string): Promise { const fileMatch = FILE_MATCH(filename); - await this.code.waitAndClick(fileMatch); - await this.code.waitForElement(`${fileMatch} .action-label.icon.action-replace-all`, el => !!el && el.top > 0 && el.left > 0); + await retry( + () => this.code.waitAndClick(fileMatch), + () => this.code.waitForElement(`${fileMatch} .action-label.icon.action-replace-all`, el => !!el && el.top > 0 && el.left > 0, 10) + ); + await this.code.waitAndClick(`${fileMatch} .action-label.icon.action-replace-all`); }