Skip to content

Commit

Permalink
Fix context test timing (#24949) (#25289)
Browse files Browse the repository at this point in the history
* Add sleeps so tests will pass

* removed a space in a comment

* replaced some sleeps with waiting for loading indicator

* Removed context page object calls from filter_bar and doc_table services
  • Loading branch information
Lee Drengenberg authored Nov 8, 2018
1 parent 772cec8 commit d012b6a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 7 deletions.
2 changes: 2 additions & 0 deletions test/functional/apps/context/_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default function ({ getService, getPageObjects }) {
it('should be toggleable via the filter bar', async function () {
const table = await docTable.getTable();
await filterBar.addFilter(TEST_ANCHOR_FILTER_FIELD, 'IS', TEST_ANCHOR_FILTER_VALUE);
await PageObjects.context.waitUntilContextLoadingHasFinished();
// disable filter
await filterBar.toggleFilterEnabled(TEST_ANCHOR_FILTER_FIELD);
await PageObjects.context.waitUntilContextLoadingHasFinished();

Expand Down
3 changes: 3 additions & 0 deletions test/functional/apps/context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ export default function ({ getService, getPageObjects, loadTestFile }) {
const remote = getService('remote');
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common']);
const kibanaServer = getService('kibanaServer');

describe('context app', function () {
before(async function () {
await remote.setWindowSize(1200, 800);
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.load('visualize');
await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC', 'defaultIndex': 'logstash-*',
'telemetry:optIn': false });
await PageObjects.common.navigateToApp('discover');
});

Expand Down
3 changes: 3 additions & 0 deletions test/functional/page_objects/context_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function ContextPageProvider({ getService, getPageObjects }) {
});

await remote.get(appUrl);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await this.waitUntilContextLoadingHasFinished();
// For lack of a better way, using a sleep to ensure page is loaded before proceeding
await PageObjects.common.sleep(1000);
Expand Down Expand Up @@ -72,6 +73,7 @@ export function ContextPageProvider({ getService, getPageObjects }) {
const predecessorButton = await this.getPredecessorLoadMoreButton();
await predecessorButton.click();
});
await this.waitUntilContextLoadingHasFinished();
await PageObjects.header.waitUntilLoadingHasFinished();
}

Expand All @@ -81,6 +83,7 @@ export function ContextPageProvider({ getService, getPageObjects }) {
const sucessorButton = await this.getSuccessorLoadMoreButton();
await sucessorButton.click();
});
await this.waitUntilContextLoadingHasFinished();
await PageObjects.header.waitUntilLoadingHasFinished();
}

Expand Down
11 changes: 7 additions & 4 deletions test/functional/page_objects/discover_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,25 +289,28 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
});
}

clickFieldListPlusFilter(field, value) {
async clickFieldListPlusFilter(field, value) {
// this method requires the field details to be open from clickFieldListItem()
// testSubjects.find doesn't handle spaces in the data-test-subj value
return getRemote()
await getRemote()
.findByCssSelector(`[data-test-subj="plus-${field}-${value}"]`)
.click();
await PageObjects.header.waitUntilLoadingHasFinished();
}

clickFieldListMinusFilter(field, value) {
async clickFieldListMinusFilter(field, value) {
// this method requires the field details to be open from clickFieldListItem()
// testSubjects.find doesn't handle spaces in the data-test-subj value
return getRemote()
await getRemote()
.findByCssSelector('[data-test-subj="minus-' + field + '-' + value + '"]')
.click();
await PageObjects.header.waitUntilLoadingHasFinished();
}

async selectIndexPattern(indexPattern) {
await getRemote().findByClassName('index-pattern-selection').click();
await getRemote().findByClassName('ui-select-search').type(indexPattern + '\n');
await PageObjects.header.waitUntilLoadingHasFinished();
}

async removeAllFilters() {
Expand Down
5 changes: 5 additions & 0 deletions test/functional/page_objects/header_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ export function HeaderPageProvider({ getService, getPageObjects }) {
await testSubjects.find('globalLoadingIndicator-hidden', defaultFindTimeout * 10);
}

async awaitKibanaChrome() {
log.debug('awaitKibanaChrome');
await testSubjects.find('kibanaChrome', defaultFindTimeout * 10);
}

async getGlobalNavigationLink(linkText) {
const nav = await testSubjects.find('globalNav');
return await nav.findByPartialLinkText(linkText);
Expand Down
9 changes: 8 additions & 1 deletion test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

import { map as mapAsync } from 'bluebird';
import expect from 'expect.js';

export function SettingsPageProvider({ getService, getPageObjects }) {
const log = getService('log');
const retry = getService('retry');
Expand Down Expand Up @@ -273,7 +275,9 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
await this.navigateTo();
await this.clickKibanaIndices();
await this.clickOptionalAddNewButton();
await this.setIndexPatternField(indexPatternName);
await retry.try(async () => {
await this.setIndexPatternField(indexPatternName);
});
await PageObjects.common.sleep(2000);
await (await this.getCreateIndexPatternGoToStep2Button()).click();
await PageObjects.common.sleep(2000);
Expand Down Expand Up @@ -323,6 +327,9 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
const field = await this.getIndexPatternField();
await field.clearValue();
await field.type(indexPatternName);
const currentName = await field.getAttribute('value');
log.debug(`setIndexPatternField set to ${currentName}`);
expect(currentName).to.eql(`${indexPatternName}*`);
}

async getCreateIndexPatternGoToStep2Button() {
Expand Down
6 changes: 5 additions & 1 deletion test/functional/services/doc_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/

export function DocTableProvider({ getService }) {
export function DocTableProvider({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'header']);


class DocTable {
async getTable() {
Expand Down Expand Up @@ -70,11 +72,13 @@ export function DocTableProvider({ getService }) {
const tableDocViewRow = await this.getTableDocViewRow(detailsRow, fieldName);
const addInclusiveFilterButton = await this.getAddInclusiveFilterButton(tableDocViewRow);
await addInclusiveFilterButton.click();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

async toggleRowExpanded(row) {
const rowExpandToggle = await this.getRowExpandToggle(row);
await rowExpandToggle.click();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();

const detailsRow = await row.findByXpath('./following-sibling::*[@data-test-subj="docTableDetailsRow"]');
return await retry.try(async () => {
Expand Down
6 changes: 5 additions & 1 deletion test/functional/services/filter_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

import Keys from 'leadfoot/keys';

export function FilterBarProvider({ getService }) {
export function FilterBarProvider({ getService, getPageObjects }) {
const remote = getService('remote');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['common', 'header']);

async function typeIntoReactSelect(testSubj, value) {
const select = await testSubjects.find(testSubj);
Expand All @@ -44,12 +45,14 @@ export function FilterBarProvider({ getService }) {
const filterElement = await testSubjects.find(`filter & filter-key-${key}`);
await remote.moveMouseTo(filterElement);
await testSubjects.click(`filter & filter-key-${key} removeFilter-${key}`);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

async toggleFilterEnabled(key) {
const filterElement = await testSubjects.find(`filter & filter-key-${key}`);
await remote.moveMouseTo(filterElement);
await testSubjects.click(`filter & filter-key-${key} disableFilter-${key}`);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

async toggleFilterPinned(key) {
Expand Down Expand Up @@ -93,6 +96,7 @@ export function FilterBarProvider({ getService }) {
}
}
await testSubjects.click('saveFilter');
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

async clickEditFilter(key, value) {
Expand Down

0 comments on commit d012b6a

Please sign in to comment.