Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTR: fix testSubjects.missingOrFail #42290

Merged
merged 3 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -434,6 +434,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 @@ -464,7 +465,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 @@ -245,6 +248,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