Skip to content

Commit

Permalink
Improve test code by using retry.try
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed May 18, 2020
1 parent 0a673db commit c3f69f3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/functional/apps/discover/_doc_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);
const esArchiver = getService('esArchiver');
const retry = getService('retry');

describe('doc link in discover', function contextSize() {
before(async function() {
Expand All @@ -36,11 +37,16 @@ export default function({ getService, getPageObjects }) {
it('should open the doc view of the selected document', async function() {
// navigate to the doc view
await docTable.clickRowToggle({ rowIndex: 0 });
await PageObjects.common.sleep(500);
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
expect(rowActions.length).to.be(2);

await rowActions[1].click();
// click the open action
await retry.try(async () => {
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
if (!rowActions.length) {
throw new Error('row actions empty, trying again');
}
await rowActions[1].click();
});

const hasDocHit = await testSubjects.exists('doc-hit');
expect(hasDocHit).to.be(true);
});
Expand Down

0 comments on commit c3f69f3

Please sign in to comment.