Skip to content

Commit

Permalink
smoketest: fix Search flakyness
Browse files Browse the repository at this point in the history
related to #51137 #49117
  • Loading branch information
joaomoreno committed Jun 6, 2018
1 parent a88680f commit 6f6320f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/vs/platform/driver/common/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface IElement {
textContent: string;
attributes: { [name: string]: string; };
children: IElement[];
top: number;
left: number;
}

export interface IDriver {
Expand Down
6 changes: 5 additions & 1 deletion src/vs/platform/driver/electron-browser/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ function serializeElement(element: Element, recursive: boolean): IElement {
}
}

const { left, top } = getTopLeftOffset(element as HTMLElement);

return {
tagName: element.tagName,
className: element.className,
textContent: element.textContent || '',
attributes,
children
children,
left,
top
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/smoke/src/areas/search/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export function setup() {
await app.workbench.search.expandReplace();
await app.workbench.search.setReplaceText('ydob');
await app.workbench.search.replaceFileMatch('app.js');

await app.workbench.search.waitForResultText('17 results in 5 files');

await app.workbench.search.searchFor('ydob');
await app.workbench.search.setReplaceText('body');
await app.workbench.search.replaceFileMatch('app.js');
await app.workbench.search.waitForNoResultText();
});
});
}
8 changes: 6 additions & 2 deletions test/smoke/src/areas/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export class Search extends Viewlet {
const fileMatch = FILE_MATCH(filename);

await this.code.waitAndClick(fileMatch);
// give time for Chrome to show the remove label
await new Promise(c => setTimeout(c, 500));
await this.code.waitForElement(`${fileMatch} .action-label.icon.action-remove`, el => !!el && el.top > 0 && el.left > 0);
await this.code.waitAndClick(`${fileMatch} .action-label.icon.action-remove`);
await this.code.waitForElement(fileMatch, el => !el);
}
Expand All @@ -79,13 +78,18 @@ export class Search extends Viewlet {
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 this.code.waitAndClick(`${fileMatch} .action-label.icon.action-replace-all`);
}

async waitForResultText(text: string): Promise<void> {
await this.code.waitForTextContent(`${VIEWLET} .messages[aria-hidden="false"] .message>p`, text);
}

async waitForNoResultText(): Promise<void> {
await this.code.waitForElement(`${VIEWLET} .messages[aria-hidden="false"] .message>p`, el => !el);
}

private async waitForInputFocus(selector: string): Promise<void> {
let retries = 0;

Expand Down

0 comments on commit 6f6320f

Please sign in to comment.