Skip to content

Commit dfb060e

Browse files
committed
Improve code
1 parent dd17012 commit dfb060e

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

test/functional/apps/context/_context_navigation.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,50 @@
1717
* under the License.
1818
*/
1919

20-
import expect from '@kbn/expect';
21-
22-
const TEST_COLUMN_NAMES = ['@message'];
2320
const TEST_FILTER_COLUMN_NAMES = [
2421
['extension', 'jpg'],
25-
['geo.src', 'IN'],
2622
[
2723
'agent',
2824
'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24',
2925
],
3026
];
3127

3228
export default function ({ getService, getPageObjects }) {
29+
const retry = getService('retry');
3330
const browser = getService('browser');
3431
const docTable = getService('docTable');
3532
const PageObjects = getPageObjects(['common', 'context', 'discover', 'timePicker']);
3633

3734
describe('context link in discover', function contextSize() {
3835
before(async function () {
36+
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
3937
await PageObjects.common.navigateToApp('discover');
40-
await PageObjects.timePicker.setDefaultAbsoluteRange();
41-
await Promise.all(
42-
TEST_COLUMN_NAMES.map((columnName) =>
43-
PageObjects.discover.clickFieldListItemAdd(columnName)
44-
)
45-
);
4638
for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) {
4739
await PageObjects.discover.clickFieldListItem(columnName);
4840
await PageObjects.discover.clickFieldListPlusFilter(columnName, value);
4941
}
5042
});
43+
after(async () => {
44+
await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings();
45+
});
5146

5247
it('should go back after loading', async function () {
53-
// navigate to the context view
54-
await docTable.clickRowToggle({ rowIndex: 0 });
55-
await (await docTable.getRowActions({ rowIndex: 0 }))[0].click();
56-
await PageObjects.context.waitUntilContextLoadingHasFinished();
57-
await PageObjects.context.clickSuccessorLoadMoreButton();
58-
await PageObjects.context.clickSuccessorLoadMoreButton();
59-
await PageObjects.context.clickSuccessorLoadMoreButton();
60-
await PageObjects.context.waitUntilContextLoadingHasFinished();
61-
await browser.goBack();
62-
await PageObjects.discover.waitForDocTableLoadingComplete();
63-
const hitCount = await PageObjects.discover.getHitCount();
64-
expect(hitCount).to.be('522');
48+
await retry.waitFor('user navigating to context and returning to discover', async () => {
49+
// navigate to the context view
50+
const initialHitCount = await PageObjects.discover.getHitCount();
51+
await docTable.clickRowToggle({ rowIndex: 0 });
52+
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
53+
await rowActions[0].click();
54+
await PageObjects.context.waitUntilContextLoadingHasFinished();
55+
await PageObjects.context.clickSuccessorLoadMoreButton();
56+
await PageObjects.context.clickSuccessorLoadMoreButton();
57+
await PageObjects.context.clickSuccessorLoadMoreButton();
58+
await PageObjects.context.waitUntilContextLoadingHasFinished();
59+
await browser.goBack();
60+
await PageObjects.discover.waitForDocTableLoadingComplete();
61+
const hitCount = await PageObjects.discover.getHitCount();
62+
return initialHitCount === hitCount;
63+
});
6564
});
6665
});
6766
}

0 commit comments

Comments
 (0)