Fix search issue on listing page + tests (#12618)

* Fix search issue on listing page + tests

* fix test case inconsistency

* use backtics to create the search string

(cherry picked from commit 31b33659ca)
This commit is contained in:
Stacey Gammon 2017-07-14 15:27:06 -04:00 committed by spalger
parent 89394b4490
commit ded1eec3ac
4 changed files with 61 additions and 2 deletions

View file

@ -175,7 +175,11 @@
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
<a class="kuiLink" ng-href="{{ listingController.getUrlForItem(item) }}">
<a
class="kuiLink"
data-test-subj="dashboardListingTitleLink"
ng-href="{{ listingController.getUrlForItem(item) }}"
>
{{ item.title }}
</a>
</div>

View file

@ -93,7 +93,7 @@ export class SavedObjectLoader {
return this.savedObjectsClient.find(
{
type: this.lowercaseType,
search,
search: `${search}*`,
perPage: size,
page: 1,
searchFields: ['title^3', 'description']

View file

@ -65,5 +65,44 @@ export default function ({ getPageObjects }) {
expect(countOfDashboards).to.equal(0);
});
});
describe('search', function () {
before(async () => {
await PageObjects.dashboard.clearSearchValue();
await PageObjects.dashboard.clickCreateDashboardPrompt();
await PageObjects.dashboard.saveDashboard('Two Words');
await PageObjects.header.clickToastOK();
});
it('matches on the first word', async function () {
await PageObjects.dashboard.searchForDashboardWithName('Two');
const countOfDashboards = await PageObjects.dashboard.getCountOfDashboardsInListingTable();
expect(countOfDashboards).to.equal(1);
});
it('matches the second word', async function () {
await PageObjects.dashboard.searchForDashboardWithName('Words');
const countOfDashboards = await PageObjects.dashboard.getCountOfDashboardsInListingTable();
expect(countOfDashboards).to.equal(1);
});
it('matches the second word prefix', async function () {
await PageObjects.dashboard.searchForDashboardWithName('Wor');
const countOfDashboards = await PageObjects.dashboard.getCountOfDashboardsInListingTable();
expect(countOfDashboards).to.equal(1);
});
it('does not match mid word', async function () {
await PageObjects.dashboard.searchForDashboardWithName('ords');
const countOfDashboards = await PageObjects.dashboard.getCountOfDashboardsInListingTable();
expect(countOfDashboards).to.equal(0);
});
it('is case insensitive', async function () {
await PageObjects.dashboard.searchForDashboardWithName('two words');
const countOfDashboards = await PageObjects.dashboard.getCountOfDashboardsInListingTable();
expect(countOfDashboards).to.equal(1);
});
});
});
}

View file

@ -270,6 +270,17 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
.click();
}
async clearSearchValue() {
log.debug(`clearSearchValue`);
await this.gotoDashboardLandingPage();
await retry.try(async () => {
const searchFilter = await testSubjects.find('searchFilter');
await searchFilter.clearValue();
});
}
async searchForDashboardWithName(dashName) {
log.debug(`searchForDashboardWithName: ${dashName}`);
@ -286,6 +297,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
await PageObjects.header.waitUntilLoadingHasFinished();
}
async getCountOfDashboardsInListingTable() {
const dashboardTitles = await testSubjects.findAll('dashboardListingTitleLink');
return dashboardTitles.length;
}
async getDashboardCountWithName(dashName) {
log.debug(`getDashboardCountWithName: ${dashName}`);