[6.x] [ftr/confirmModal] assert expected state rather than just reading (#20019) (#20022)

Backports the following commits to 6.x:
 - [ftr/confirmModal] assert expected state rather than just reading  (#20019)
This commit is contained in:
Spencer 2018-06-19 13:11:38 -07:00 committed by GitHub
parent 3f2b5d5518
commit 20a932e03e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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() {