Skip to content

Commit

Permalink
Merge pull request #8363 from spalger/fix/functional-tests/index-fiel…
Browse files Browse the repository at this point in the history
…ds-failure

Fix functional tests - index fields failure
  • Loading branch information
spalger authored Sep 20, 2016
2 parents e20afd9 + 52dbb26 commit 3595b5b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ uiModules.get('apps/management')
{
markup: nameHtml,
scope: childScope,
value: field.displayName
value: field.displayName,
attr: {
'data-test-subj': 'indexedFieldName'
}
},
{
markup: typeHtml,
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/directives/rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private
} else {
$cell.html(contents.markup);
}

if (contents.attr) {
$cell.attr(contents.attr);
}
} else {
if (contents === '') {
$cell.html(' ');
Expand Down
44 changes: 18 additions & 26 deletions test/functional/apps/management/_index_pattern_results_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ bdd.describe('index result field sort', function describeIndexTests() {
});

bdd.describe('field list pagination', function () {
var expectedDefaultPageSize = 25;
var expectedFieldCount = 85;
var expectedLastPageCount = 10;
var pages = [1, 2, 3, 4];
const EXPECTED_DEFAULT_PAGE_SIZE = 25;
const EXPECTED_FIELD_COUNT = 85;
const EXPECTED_LAST_PAGE_COUNT = 10;
const LAST_PAGE_NUMBER = 4;

bdd.before(function () {
return PageObjects.settings.navigateTo()
Expand All @@ -97,38 +97,30 @@ bdd.describe('index result field sort', function describeIndexTests() {
return PageObjects.common.try(function () {
return PageObjects.settings.getFieldsTabCount()
.then(function (tabCount) {
expect(tabCount).to.be('' + expectedFieldCount);
expect(tabCount).to.be('' + EXPECTED_FIELD_COUNT);
});
});
});

bdd.it('should have correct default page size selected', function () {
return PageObjects.settings.getPageSize()
.then(function (pageSize) {
expect(pageSize).to.be('' + expectedDefaultPageSize);
expect(pageSize).to.be('' + EXPECTED_DEFAULT_PAGE_SIZE);
});
});

bdd.it('should have the correct number of rows per page', function () {
var pageCount = Math.ceil(expectedFieldCount / expectedDefaultPageSize);
var chain = pages.reduce(function (chain, val) {
return chain.then(function () {
return PageObjects.settings.goToPage(val)
.then(function () {
return PageObjects.common.sleep(1000);
})
.then(function () {
return PageObjects.settings.getPageFieldCount();
})
.then(function (pageCount) {
PageObjects.common.saveScreenshot('Settings-indices-paged');
var expectedSize = (val < 4) ? expectedDefaultPageSize : expectedLastPageCount;
expect(pageCount.length).to.be(expectedSize);
});
});
}, Promise.resolve());

return chain.catch(PageObjects.common.createErrorHandler(this));
bdd.it('should have the correct number of rows per page', async function () {
for (let pageNum = 1; pageNum <= LAST_PAGE_NUMBER; pageNum += 1) {
await PageObjects.settings.goToPage(pageNum);
const pageFieldNames = await PageObjects.common.tryMethod(PageObjects.settings, 'getFieldNames');
await PageObjects.common.saveScreenshot(`Settings-indexed-fields-page-${pageNum}`);

if (pageNum === LAST_PAGE_NUMBER) {
expect(pageFieldNames).to.have.length(EXPECTED_LAST_PAGE_COUNT);
} else {
expect(pageFieldNames).to.have.length(EXPECTED_DEFAULT_PAGE_SIZE);
}
}
});
}); // end describe pagination
}); // end index result field sort
10 changes: 6 additions & 4 deletions test/support/page_objects/settings_page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import Bluebird from 'bluebird';
import Bluebird, { map as mapAsync } from 'bluebird';

import {
defaultFindTimeout,
Expand Down Expand Up @@ -231,9 +231,11 @@ export default class SettingsPage {
});
}

getPageFieldCount() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr td.ng-scope:nth-child(1) span.ng-binding');
async getFieldNames() {
const fieldNameCells = await PageObjects.common.findAllTestSubjects('editIndexPattern indexedFieldName');
return await mapAsync(fieldNameCells, async cell => {
return (await cell.getVisibleText()).trim();
});
}

goToPage(pageNum) {
Expand Down

0 comments on commit 3595b5b

Please sign in to comment.