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

I've seen a few failures recently like https://kibana-ci.elastic.co/job/elastic+kibana+pull-request+multijob-selenium/4940/console which are caused by the modal not being visible, but if you look at the screenshot you can see the the modal was just about to be displayed but the find didn't wait quite long enough. ~~To fix this temporarily I've increased the `isConfirmModalOpen()` timeout from 2 to 5 seconds.~~

These tests are actually trying to assert that the modal is gone, so rather than simply checking the state of the modal once, the `CommonPage#isConfirmModalOpen()` method has been renamed to `CommonPage#expectConfirmModalOpenState()` which expects a boolean and will assert the state of the confirm modal within a retry, so that as long as the modal eventually transitions to that state it will eventually resolve.

![dashboard app using legacy data dashboard listing page delete default confirm action is cancel 1](https://user-images.githubusercontent.com/1329312/41569272-3215b4aa-731f-11e8-864a-0c0022228245.png)
This commit is contained in:
Spencer 2018-06-18 21:05:21 -07:00 committed by GitHub
parent 6f7dfcfff2
commit b25ab869f7
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() {