diff --git a/test/functional/apps/dashboard/_dashboard_listing.js b/test/functional/apps/dashboard/_dashboard_listing.js index 208ac30e83c7..1273b85314a5 100644 --- a/test/functional/apps/dashboard/_dashboard_listing.js +++ b/test/functional/apps/dashboard/_dashboard_listing.js @@ -67,8 +67,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.common.pressEnterKey(); - const isConfirmOpen = await PageObjects.common.isConfirmModalOpen(); - expect(isConfirmOpen).to.be(false); + await PageObjects.common.expectConfirmModalOpenState(false); const countOfDashboards = await PageObjects.dashboard.getDashboardCountWithName(dashboardName); expect(countOfDashboards).to.equal(1); diff --git a/test/functional/apps/dashboard/_view_edit.js b/test/functional/apps/dashboard/_view_edit.js index 0d1d1be7d874..f99e59323aa2 100644 --- a/test/functional/apps/dashboard/_view_edit.js +++ b/test/functional/apps/dashboard/_view_edit.js @@ -209,8 +209,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.header.setAbsoluteRange('2014-10-19 06:31:44.000', '2014-12-19 06:31:44.000'); await PageObjects.dashboard.clickCancelOutOfEditMode(); - const isOpen = await PageObjects.common.isConfirmModalOpen(); - expect(isOpen).to.be(false); + await PageObjects.common.expectConfirmModalOpenState(false); }); // See https://github.com/elastic/kibana/issues/10110 - this is intentional. @@ -222,8 +221,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.dashboard.clickCancelOutOfEditMode(); - const isOpen = await PageObjects.common.isConfirmModalOpen(); - expect(isOpen).to.be(false); + await PageObjects.common.expectConfirmModalOpenState(false); await PageObjects.dashboard.loadSavedDashboard(dashboardName); const query = await queryBar.getQueryString(); diff --git a/test/functional/page_objects/common_page.js b/test/functional/page_objects/common_page.js index 1fa5276f2244..fbf74f0453f4 100644 --- a/test/functional/page_objects/common_page.js +++ b/test/functional/page_objects/common_page.js @@ -18,6 +18,7 @@ */ import { delay } from 'bluebird'; +import expect from 'expect.js'; import getUrl from '../../../src/test_utils/get_url'; @@ -260,9 +261,20 @@ export function CommonPageProvider({ getService, getPageObjects }) { } } - async isConfirmModalOpen() { - log.debug('isConfirmModalOpen'); - return await testSubjects.exists('confirmModalCancelButton', 2000); + async expectConfirmModalOpenState(state) { + if (typeof state !== 'boolean') { + throw new Error('pass true or false to expectConfirmModalOpenState()'); + } + + log.debug(`expectConfirmModalOpenState(${state})`); + + // we use retry here instead of a simple .exists() check because the modal + // fades in/out, which takes time, and we really only care that at some point + // the modal is either open or closed + await retry.try(async () => { + const actualState = await testSubjects.exists('confirmModalCancelButton'); + expect(actualState).to.be(state); + }); } async getBreadcrumbPageTitle() {