Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jun 12, 2020
1 parent dd17012 commit dfb060e
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions test/functional/apps/context/_context_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,50 @@
* under the License.
*/

import expect from '@kbn/expect';

const TEST_COLUMN_NAMES = ['@message'];
const TEST_FILTER_COLUMN_NAMES = [
['extension', 'jpg'],
['geo.src', 'IN'],
[
'agent',
'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24',
],
];

export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const browser = getService('browser');
const docTable = getService('docTable');
const PageObjects = getPageObjects(['common', 'context', 'discover', 'timePicker']);

describe('context link in discover', function contextSize() {
before(async function () {
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
await Promise.all(
TEST_COLUMN_NAMES.map((columnName) =>
PageObjects.discover.clickFieldListItemAdd(columnName)
)
);
for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) {
await PageObjects.discover.clickFieldListItem(columnName);
await PageObjects.discover.clickFieldListPlusFilter(columnName, value);
}
});
after(async () => {
await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings();
});

it('should go back after loading', async function () {
// navigate to the context view
await docTable.clickRowToggle({ rowIndex: 0 });
await (await docTable.getRowActions({ rowIndex: 0 }))[0].click();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await browser.goBack();
await PageObjects.discover.waitForDocTableLoadingComplete();
const hitCount = await PageObjects.discover.getHitCount();
expect(hitCount).to.be('522');
await retry.waitFor('user navigating to context and returning to discover', async () => {
// navigate to the context view
const initialHitCount = await PageObjects.discover.getHitCount();
await docTable.clickRowToggle({ rowIndex: 0 });
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
await rowActions[0].click();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await browser.goBack();
await PageObjects.discover.waitForDocTableLoadingComplete();
const hitCount = await PageObjects.discover.getHitCount();
return initialHitCount === hitCount;
});
});
});
}

0 comments on commit dfb060e

Please sign in to comment.