Wait for saveSearch to reload, retry on openSavedSearch (#21371) (#21494)

* Wait for saveSearch to reload, retry on openSavedSearch

* Added comments and moved a waitUntilLoadingHasFinished
This commit is contained in:
Lee Drengenberg 2018-08-28 16:57:37 -05:00 committed by GitHub
parent 2e2964fa92
commit 8bd1b047dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,8 @@
* under the License.
*/
import expect from 'expect.js';
export function DiscoverPageProvider({ getService, getPageObjects }) {
const config = getService('config');
const log = getService('log');
@ -53,6 +55,15 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
await getRemote().findDisplayedById('SaveSearch').pressKeys(searchName);
await testSubjects.click('discoverSaveSearchButton');
await PageObjects.header.waitUntilLoadingHasFinished();
// 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);
});
}
async getColumnHeaders() {
@ -61,9 +72,14 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
}
async openSavedSearch() {
await this.clickLoadSavedSearchButton();
await testSubjects.exists('loadSearchForm');
await PageObjects.header.waitUntilLoadingHasFinished();
// 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 this.clickLoadSavedSearchButton();
await PageObjects.header.waitUntilLoadingHasFinished();
const loadIsOpen = await testSubjects.exists('loadSearchForm');
expect(loadIsOpen).to.be(true);
});
}
async hasSavedSearch(searchName) {