Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jun 3, 2020
1 parent 13f6583 commit bca2233
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions test/functional/apps/context/_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';

const TEST_INDEX_PATTERN = 'logstash-*';
const TEST_ANCHOR_ID = 'AU_x3_BrGFA8no6QjjaI';
const TEST_DEFAULT_CONTEXT_SIZE = 7;
const TEST_STEP_SIZE = 3;
const TEST_DEFAULT_CONTEXT_SIZE = 2;
const TEST_STEP_SIZE = 2;

export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const docTable = getService('docTable');
const PageObjects = getPageObjects(['context']);
let rowLength = 2 * TEST_DEFAULT_CONTEXT_SIZE + 1;

// eslint-disable-next-line mocha/no-exclusive-tests
describe.only('context size', function contextSize() {
Expand All @@ -37,48 +35,48 @@ export default function ({ getService, getPageObjects }) {
'context:defaultSize': `${TEST_DEFAULT_CONTEXT_SIZE}`,
'context:step': `${TEST_STEP_SIZE}`,
});
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_ID);
});

it('should default to the `context:defaultSize` setting', async function () {
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_ID);

await retry.try(async function () {
expect(await docTable.getRowsText()).to.have.length(2 * TEST_DEFAULT_CONTEXT_SIZE + 1);
});
await retry.try(async function () {
const predecessorCountPicker = await PageObjects.context.getPredecessorCountPicker();
expect(await predecessorCountPicker.getAttribute('value')).to.equal(
`${TEST_DEFAULT_CONTEXT_SIZE}`
);
});
await retry.try(async function () {
const successorCountPicker = await PageObjects.context.getSuccessorCountPicker();
expect(await successorCountPicker.getAttribute('value')).to.equal(
`${TEST_DEFAULT_CONTEXT_SIZE}`
);
await retry.waitFor(`number of rows displayed initially is ${rowLength}`, async function () {
const rows = await docTable.getRowsText();
return rows.length === rowLength;
});
await retry.waitFor(
`predecessor count picker is set to ${TEST_DEFAULT_CONTEXT_SIZE}`,
async function () {
const predecessorCountPicker = await PageObjects.context.getPredecessorCountPicker();
const value = await predecessorCountPicker.getAttribute('value');
return value === String(TEST_DEFAULT_CONTEXT_SIZE);
}
);
});

it('should increase according to the `context:step` setting when clicking the `load newer` button', async function () {
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_ID);
await PageObjects.context.clickPredecessorLoadMoreButton();
rowLength += TEST_STEP_SIZE;

await retry.try(async function () {
expect(await docTable.getRowsText()).to.have.length(
2 * TEST_DEFAULT_CONTEXT_SIZE + TEST_STEP_SIZE + 1
);
});
await retry.waitFor(
`number of rows displayed after clicking load more predecessors is ${rowLength}`,
async function () {
const rows = await docTable.getRowsText();
return rows.length === rowLength;
}
);
});

it('should increase according to the `context:step` setting when clicking the `load older` button', async function () {
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, TEST_ANCHOR_ID);
await PageObjects.context.clickSuccessorLoadMoreButton();
rowLength += TEST_STEP_SIZE;

await retry.try(async function () {
expect(await docTable.getRowsText()).to.have.length(
2 * TEST_DEFAULT_CONTEXT_SIZE + TEST_STEP_SIZE + 1
);
});
await retry.waitFor(
`number of rows displayed after clicking load more successors is ${rowLength}`,
async function () {
const rows = await docTable.getRowsText();
return rows.length === rowLength;
}
);
});
});
}

0 comments on commit bca2233

Please sign in to comment.