Skip to content

Commit

Permalink
FTR: fix testSubjects.missingOrFail (#42290) (#42323)
Browse files Browse the repository at this point in the history
* [services/test_subject] fix missingOrFail

* [services/test_subjects] allowHidden option for missingOrFail

* [page_objects/dashboard_page] wait for euiTable loaded, increase timeout for loading page check
  • Loading branch information
dmlemeshko authored Jul 31, 2019
1 parent d2ec9f0 commit d118d7e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
// Note: this replacement of - to space is to preserve original logic but I'm not sure why or if it's needed.
await searchFilter.type(dashName.replace('-', ' '));
await PageObjects.common.pressEnterKey();
await find.waitForDeletedByCssSelector('.euiBasicTable-loading', 5000);
});

await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -461,7 +462,7 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
await this.selectDashboard(dashName);
await PageObjects.header.waitUntilLoadingHasFinished();
// check Dashboard landing page is not present
await testSubjects.missingOrFail('newItemButton');
await testSubjects.missingOrFail('dashboardLandingPage', { timeout: 10000 });
});
}

Expand Down
4 changes: 2 additions & 2 deletions test/functional/page_objects/discover_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
}

async expectMissingFieldListItemVisualize(field) {
await testSubjects.missingOrFail(`fieldVisualize-${field}`);
await testSubjects.missingOrFail(`fieldVisualize-${field}`, { allowHidden: true });
}

async clickFieldListPlusFilter(field, value) {
Expand Down Expand Up @@ -288,7 +288,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
const fieldFilterFormExists = await testSubjects.exists('discoverFieldFilter');
if (fieldFilterFormExists) {
await testSubjects.click('toggleFieldFilterButton');
await testSubjects.missingOrFail('discoverFieldFilter');
await testSubjects.missingOrFail('discoverFieldFilter', { allowHidden: true });
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/functional/services/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function FindProvider({ getService }: FtrProviderContext) {
const browserType = webdriver.browserType;

const WAIT_FOR_EXISTS_TIME = config.get('timeouts.waitForExists');
const POLLING_TIME = 500;
const defaultFindTimeout = config.get('timeouts.find');
const fixedHeaderHeight = config.get('layout.fixedHeaderHeight');

Expand Down Expand Up @@ -426,7 +427,7 @@ export async function FindProvider({ getService }: FtrProviderContext) {
timeout: number = defaultFindTimeout
) {
log.debug(`Find.waitForDeletedByCssSelector('${selector}') with timeout=${timeout}`);
await this._withTimeout(1000);
await this._withTimeout(POLLING_TIME);
await driver.wait(
async () => {
const found = await driver.findElements(By.css(selector));
Expand Down
17 changes: 13 additions & 4 deletions test/functional/services/test_subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {

public async missingOrFail(
selector: string,
existsOptions?: ExistsOptions
options: ExistsOptions = {}
): Promise<void | never> {
if (await this.exists(selector, existsOptions)) {
throw new Error(`expected testSubject(${selector}) to not exist`);
}
const { timeout = WAIT_FOR_EXISTS_TIME, allowHidden = false } = options;

log.debug(`TestSubjects.missingOrFail(${selector})`);
return await (allowHidden
? this.waitForHidden(selector, timeout)
: find.waitForDeletedByCssSelector(testSubjSelector(selector), timeout));
}

public async append(selector: string, text: string): Promise<void> {
Expand Down Expand Up @@ -260,6 +263,12 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
await find.waitForAttributeToChange(testSubjSelector(selector), attribute, value);
}

public async waitForHidden(selector: string, timeout?: number): Promise<void> {
log.debug(`TestSubjects.waitForHidden(${selector})`);
const element = await this.find(selector);
await find.waitForElementHidden(element, timeout);
}

public getCssSelector(selector: string): string {
return testSubjSelector(selector);
}
Expand Down

0 comments on commit d118d7e

Please sign in to comment.