Fix flaky context _size tests and bug in context page object file (#20254)
* Update getSuccessorLoadMoreButton() to point to correct selector Add a sleep in navigateTo() and remove refresh() Add methods to click predecessor and successor load more buttons Update waitUntilContextLoadingHasFinished to check buttons are enabled and displayed Update tests to use click methods * Fix lint issues
This commit is contained in:
parent
f763c3eb67
commit
5613d325bb
2 changed files with 33 additions and 11 deletions
|
@ -26,7 +26,6 @@ const TEST_DEFAULT_CONTEXT_SIZE = 7;
|
|||
const TEST_STEP_SIZE = 3;
|
||||
|
||||
export default function ({ getService, getPageObjects }) {
|
||||
const remote = getService('remote');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const retry = getService('retry');
|
||||
const docTable = getService('docTable');
|
||||
|
@ -61,7 +60,8 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_TYPE, TEST_ANCHOR_ID);
|
||||
|
||||
const table = await docTable.getTable();
|
||||
await (await PageObjects.context.getPredecessorLoadMoreButton()).click();
|
||||
await PageObjects.context.clickPredecessorLoadMoreButton();
|
||||
|
||||
await retry.try(async function () {
|
||||
expect(await docTable.getBodyRows(table)).to.have.length(
|
||||
2 * TEST_DEFAULT_CONTEXT_SIZE + TEST_STEP_SIZE + 1
|
||||
|
@ -73,9 +73,8 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_TYPE, TEST_ANCHOR_ID);
|
||||
|
||||
const table = await docTable.getTable();
|
||||
const successorLoadMoreButton = await PageObjects.context.getSuccessorLoadMoreButton();
|
||||
await remote.moveMouseTo(successorLoadMoreButton); // possibly scroll until the button is visible
|
||||
await successorLoadMoreButton.click();
|
||||
await PageObjects.context.clickSuccessorLoadMoreButton();
|
||||
|
||||
await retry.try(async function () {
|
||||
expect(await docTable.getBodyRows(table)).to.have.length(
|
||||
2 * TEST_DEFAULT_CONTEXT_SIZE + TEST_STEP_SIZE + 1
|
||||
|
|
|
@ -25,11 +25,13 @@ const DEFAULT_INITIAL_STATE = {
|
|||
columns: ['@message'],
|
||||
};
|
||||
|
||||
export function ContextPageProvider({ getService }) {
|
||||
export function ContextPageProvider({ getService, getPageObjects }) {
|
||||
const remote = getService('remote');
|
||||
const config = getService('config');
|
||||
const retry = getService('retry');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const PageObjects = getPageObjects(['header', 'common']);
|
||||
const log = getService('log');
|
||||
|
||||
class ContextPage {
|
||||
async navigateTo(indexPattern, anchorType, anchorId, overrideInitialState = {}) {
|
||||
|
@ -43,8 +45,9 @@ export function ContextPageProvider({ getService }) {
|
|||
});
|
||||
|
||||
await remote.get(appUrl);
|
||||
await remote.refresh();
|
||||
await this.waitUntilContextLoadingHasFinished();
|
||||
// For lack of a better way, using a sleep to ensure page is loaded before proceeding
|
||||
await PageObjects.common.sleep(1000);
|
||||
}
|
||||
|
||||
async getPredecessorCountPicker() {
|
||||
|
@ -60,18 +63,38 @@ export function ContextPageProvider({ getService }) {
|
|||
}
|
||||
|
||||
async getSuccessorLoadMoreButton() {
|
||||
return await testSubjects.find('predecessorLoadMoreButton');
|
||||
return await testSubjects.find('successorLoadMoreButton');
|
||||
}
|
||||
|
||||
waitUntilContextLoadingHasFinished() {
|
||||
return retry.try(async () => {
|
||||
async clickPredecessorLoadMoreButton() {
|
||||
log.debug('Click Predecessor Load More Button');
|
||||
await retry.try(async () => {
|
||||
const predecessorButton = await this.getPredecessorLoadMoreButton();
|
||||
await predecessorButton.click();
|
||||
});
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
async clickSuccessorLoadMoreButton() {
|
||||
log.debug('Click Successor Load More Button');
|
||||
await retry.try(async () => {
|
||||
const sucessorButton = await this.getSuccessorLoadMoreButton();
|
||||
await sucessorButton.click();
|
||||
});
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
async waitUntilContextLoadingHasFinished() {
|
||||
return await retry.try(async () => {
|
||||
const successorLoadMoreButton = await this.getSuccessorLoadMoreButton();
|
||||
const predecessorLoadMoreButton = await this.getPredecessorLoadMoreButton();
|
||||
if (!successorLoadMoreButton.isEnabled() || !predecessorLoadMoreButton.isEnabled()) {
|
||||
if (!(successorLoadMoreButton.isEnabled() && successorLoadMoreButton.isDisplayed() &&
|
||||
predecessorLoadMoreButton.isEnabled() && predecessorLoadMoreButton.isDisplayed())) {
|
||||
throw new Error('loading context rows');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new ContextPage();
|
||||
|
|
Loading…
Reference in a new issue