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

[Discover] Improve saveSearch functional test handling #73626

Merged
Changes from 1 commit
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
21 changes: 10 additions & 11 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
* under the License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

export function DiscoverPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const find = getService('find');
Expand Down Expand Up @@ -51,19 +49,20 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
}

public async saveSearch(searchName: string) {
log.debug('saveSearch');
await this.clickSaveSearchButton();
await testSubjects.setValue('savedObjectTitle', searchName);
await testSubjects.click('confirmSaveSavedObjectButton');
await header.waitUntilLoadingHasFinished();
// preventing an occasional flakiness when the saved object wasn't set and the form can't be submitted
await retry.waitFor(`saved search can be persisted name ${searchName}`, async () => {
await testSubjects.setValue('savedObjectTitle', searchName);
await testSubjects.click('confirmSaveSavedObjectButton');
return (await header.isGlobalLoadingIndicatorVisible()) === true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we might need to wait for popup to disappear
return (await testSubjects.exists('confirmSaveSavedObjectButton', { timeout: 5000 })) === false

Is there a chance that popup will remain in place and header.isGlobalLoadingIndicatorVisible() will return true ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point 👍 , I will take a closer look here!

Copy link
Contributor

@LeeDr LeeDr Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can always catch the loading indicator after clicking save. Could it be that in some cases the save is quick enough that we never see the loading indicator?

Also, if we do find the loading indicator, I think we should then wait for it to be hidden before returning from saveSearch method. I think waitUntilLoadingHasFinished was doing that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the code to check for the save button not to be disabled, this should catch the occasional
flakiness when for whatever reason the title wasn't entered, and the save button stayed disabled therefore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
// LeeDr - this additional checking for the saved search name was an attempt
// to cause this method to wait for the reloading of the page to complete so
// that the next action wouldn't have to retry. But it doesn't really solve
// that issue. But it does typically take about 3 retries to
// complete with the expected searchName.
await retry.try(async () => {
const name = await this.getCurrentQueryName();
expect(name).to.be(searchName);
await retry.waitFor(`saved search was persisted with name ${searchName}`, async () => {
return (await this.getCurrentQueryName()) === searchName;
});
}

Expand Down Expand Up @@ -96,11 +95,11 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider

// We need this try loop here because previous actions in Discover like
// saving a search cause reloading of the page and the "Open" menu item goes stale.
await retry.try(async () => {
await retry.waitFor('saved search panel is opened', async () => {
await this.clickLoadSavedSearchButton();
await header.waitUntilLoadingHasFinished();
isOpen = await testSubjects.exists('loadSearchForm');
expect(isOpen).to.be(true);
return isOpen === true;
});
}

Expand Down