diff --git a/test/functional/apps/context/_context_navigation.js b/test/functional/apps/context/_context_navigation.js index 5acc14330832ce..52d7891887708b 100644 --- a/test/functional/apps/context/_context_navigation.js +++ b/test/functional/apps/context/_context_navigation.js @@ -17,12 +17,8 @@ * under the License. */ -import expect from '@kbn/expect'; - -const TEST_COLUMN_NAMES = ['@message']; const TEST_FILTER_COLUMN_NAMES = [ ['extension', 'jpg'], - ['geo.src', 'IN'], [ 'agent', 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24', @@ -30,38 +26,41 @@ const TEST_FILTER_COLUMN_NAMES = [ ]; export default function ({ getService, getPageObjects }) { + const retry = getService('retry'); const browser = getService('browser'); const docTable = getService('docTable'); const PageObjects = getPageObjects(['common', 'context', 'discover', 'timePicker']); describe('context link in discover', function contextSize() { before(async function () { + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await Promise.all( - TEST_COLUMN_NAMES.map((columnName) => - PageObjects.discover.clickFieldListItemAdd(columnName) - ) - ); for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { await PageObjects.discover.clickFieldListItem(columnName); await PageObjects.discover.clickFieldListPlusFilter(columnName, value); } }); + after(async () => { + await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + }); it('should go back after loading', async function () { - // navigate to the context view - await docTable.clickRowToggle({ rowIndex: 0 }); - await (await docTable.getRowActions({ rowIndex: 0 }))[0].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); - await PageObjects.context.clickSuccessorLoadMoreButton(); - await PageObjects.context.clickSuccessorLoadMoreButton(); - await PageObjects.context.clickSuccessorLoadMoreButton(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); - await browser.goBack(); - await PageObjects.discover.waitForDocTableLoadingComplete(); - const hitCount = await PageObjects.discover.getHitCount(); - expect(hitCount).to.be('522'); + await retry.waitFor('user navigating to context and returning to discover', async () => { + // navigate to the context view + const initialHitCount = await PageObjects.discover.getHitCount(); + await docTable.clickRowToggle({ rowIndex: 0 }); + const rowActions = await docTable.getRowActions({ rowIndex: 0 }); + await rowActions[0].click(); + await PageObjects.context.waitUntilContextLoadingHasFinished(); + await PageObjects.context.clickSuccessorLoadMoreButton(); + await PageObjects.context.clickSuccessorLoadMoreButton(); + await PageObjects.context.clickSuccessorLoadMoreButton(); + await PageObjects.context.waitUntilContextLoadingHasFinished(); + await browser.goBack(); + await PageObjects.discover.waitForDocTableLoadingComplete(); + const hitCount = await PageObjects.discover.getHitCount(); + return initialHitCount === hitCount; + }); }); }); }