[ADF-3677] Add highlight configuration to SearchQueryBuilder (#4358)

* [ADF-3677] Add highlight configuration to SearchQueryBuilder

* highlight property in search

* Update files.component.ts

* remove comma

* highlight missspell

* fix schhema json highilight

* fix test

* fix lint

* fix lint

* fix lint

* fix search sorting tests

* fix search sorting

* fix lint

* remove useless test

* check for null nodes

* remove duplicated test

* lint

* fix sorting tests

* remove test not search component related
This commit is contained in:
davidcanonieto
2019-03-17 17:23:07 +00:00
committed by Eugenio Romano
parent d6f391c40e
commit 8dc9eba4c7
19 changed files with 401 additions and 444 deletions
+13 -21
View File
@@ -120,7 +120,7 @@ describe('Search Date Range Filter', () => {
.selectTodayDate()
.checkDatePickerIsNotDisplayed();
dateRangeFilter.getFromDate().then((date) => {
fromDate = DateUtil.formatDate('DD-MM-YY', date);
fromDate = DateUtil.formatDate('DD-MM-YY', DateUtil.parse(date, 'DD-MMM-YY'));
});
dateRangeFilter.checkApplyButtonIsDisabled();
@@ -129,34 +129,26 @@ describe('Search Date Range Filter', () => {
.selectTodayDate()
.checkDatePickerIsNotDisplayed();
dateRangeFilter.getToDate().then((date) => {
toDate = DateUtil.formatDate('DD-MM-YY', date);
toDate = DateUtil.formatDate('DD-MM-YY', DateUtil.parse(date, 'DD-MMM-YY'), 1);
});
dateRangeFilter.checkApplyButtonIsEnabled()
.clickApplyButton();
searchResults.sortByCreated(true);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
let nodeCreation = new Date(node.entry.createdAt);
nodeCreation.setHours(0, 0, 0, 0);
await expect(nodeCreation.getTime() >= DateUtil.parse(fromDate).getTime()).toBe(true);
await expect(nodeCreation.getTime() <= DateUtil.parse(toDate).getTime()).toBe(true);
});
});
searchResults.sortByCreated(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
let nodeCreation = new Date(node.entry.createdAt);
nodeCreation.setHours(0, 0, 0, 0);
await expect(nodeCreation.getTime() >= DateUtil.parse(fromDate).getTime()).toBe(true);
await expect(nodeCreation.getTime() <= DateUtil.parse(toDate).getTime()).toBe(true);
});
let results = await dataTable.geCellElementDetail('Created');
for (let currentResult of results) {
currentResult.getAttribute('title').then(async (currentDate) => {
let currentDateFormatted = DateUtil.parse(currentDate, 'MMM DD, YYYY, h:mm:ss a');
await expect(currentDateFormatted <= DateUtil.parse(toDate, 'DD-MM-YY')).toBe(true);
await expect(currentDateFormatted >= DateUtil.parse(fromDate, 'DD-MM-YY')).toBe(true);
});
}
});
});
@@ -32,6 +32,7 @@ import { FileModel } from '../../models/ACS/fileModel';
import { browser } from 'protractor';
import resources = require('../../util/resources');
import { SearchConfiguration } from '../search.config';
import { DateUtil } from '../../util/dateUtil';
describe('Search Number Range Filter', () => {
@@ -171,10 +172,16 @@ describe('Search Number Range Filter', () => {
searchResults.sortBySize(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= toSize).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) <= toSize).toBe(true);
}
} catch (e) {
}
}
});
});
@@ -196,10 +203,16 @@ describe('Search Number Range Filter', () => {
searchResults.sortBySize(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= toSize).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) <= toSize).toBe(true);
}
} catch (e) {
}
}
});
searchFilters.checkNameFilterIsDisplayed()
@@ -208,63 +221,30 @@ describe('Search Number Range Filter', () => {
searchResults.sortBySize(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= toSize).toBe(true);
let name = node.entry.name;
await expect(/z*/i.test(name)).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) <= toSize).toBe(true);
}
} catch (e) {
}
}
});
});
it('[C276950] Should be able to filter by size (slider) when size range filter is applied', () => {
let sizeSliderFilter = searchFilters.sizeSliderFilterPage();
let toSize = 20;
let sliderSize = 18;
searchFilters.checkSizeSliderFilterIsDisplayed()
.clickSizeSliderFilterHeader()
.checkSizeSliderFilterIsExpanded();
sizeSliderFilter.checkSliderIsDisplayed().setValue(sliderSize);
sizeRangeFilter.checkFromFieldIsDisplayed()
.putFromNumber(0)
.putToNumber(toSize);
expect(sizeRangeFilter.checkApplyButtonIsEnabled()).toBe(true);
sizeRangeFilter.clickApplyButton();
searchResults.sortBySize(false);
searchResults.tableIsLoaded();
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= sliderSize).toBe(true);
});
let results = await dataTable.geCellElementDetail('Display name');
for (let currentResult of results) {
try {
let name = await currentResult.getAttribute('title');
if (name && name.trim() !== '') {
await expect(/z*/i.test(name)).toBe(true);
}
} catch (e) {
}
}
});
sizeRangeFilter.checkFromFieldIsDisplayed()
.putFromNumber(1);
expect(sizeRangeFilter.checkApplyButtonIsEnabled()).toBe(true);
sizeRangeFilter.clickApplyButton();
searchResults.sortBySize(true);
searchResults.tableIsLoaded();
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes >= 1).toBe(true);
await expect(node.entry.content.sizeInBytes <= sliderSize).toBe(true);
});
});
sizeRangeFilter.checkFromFieldIsDisplayed()
.putFromNumber(19);
expect(sizeRangeFilter.checkApplyButtonIsEnabled()).toBe(true);
sizeRangeFilter.clickApplyButton();
searchResults.checkNoResultMessageIsDisplayed();
});
it('[C276951] Should not display folders when Size range is applied', () => {
@@ -297,11 +277,18 @@ describe('Search Number Range Filter', () => {
searchResults.sortBySize(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes).toEqual(0);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(currentSize === '0').toBe(true);
}
} catch (e) {
}
}
});
});
it('[C277092] Should disable apply button when from field value equal/is bigger than to field value', () => {
@@ -328,10 +315,17 @@ describe('Search Number Range Filter', () => {
searchResults.sortBySize(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= 1).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) <= 1000).toBe(true);
}
} catch (e) {
}
}
});
sizeRangeFilter.clickClearButton();
@@ -340,10 +334,17 @@ describe('Search Number Range Filter', () => {
expect(sizeRangeFilter.getToNumber()).toEqual('');
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes >= 1).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) >= 1000).toBe(true);
}
} catch (e) {
}
}
});
});
@@ -426,20 +427,18 @@ describe('Search Number Range Filter', () => {
searchResults.sortByCreated(false);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect((node.entry.createdAt.getFullYear()) <= toYear).toBe(true);
});
let results = await dataTable.geCellElementDetail('Created');
for (let currentResult of results) {
currentResult.getAttribute('title').then(async (currentDate) => {
let currentDateFormatted = DateUtil.parse(currentDate, 'MMM DD, YYYY, h:mm:ss a');
await expect(currentDateFormatted.getFullYear() <= toYear).toBe(true);
await expect(currentDateFormatted.getFullYear() >= fromYear).toBe(true);
});
}
});
searchResults.sortByCreated(true);
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect((node.entry.createdAt.getFullYear()) >= fromYear).toBe(true);
});
});
});
it('[C277139] Should be able to set To field to be exclusive', () => {
+21 -8
View File
@@ -123,10 +123,16 @@ describe('Search Number Range Filter', () => {
.tableIsLoaded();
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes <= size).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) <= 5000).toBe(true);
}
} catch (e) {
}
}
});
sizeSliderFilter.checkSliderIsDisplayed()
@@ -136,10 +142,17 @@ describe('Search Number Range Filter', () => {
.tableIsLoaded();
browser.controlFlow().execute(async () => {
let firstResult = await dataTable.getFirstElementDetail('Node id');
await this.alfrescoJsApi.core.nodesApi.getNode(firstResult).then(async (node) => {
await expect(node.entry.content.sizeInBytes >= size).toBe(true);
});
let results = await dataTable.geCellElementDetail('Size');
for (let currentResult of results) {
try {
let currentSize = await currentResult.getAttribute('title');
if (currentSize && currentSize.trim() !== '') {
await expect(parseInt(currentSize, 10) >= 5000).toBe(true);
}
} catch (e) {
}
}
});
});
@@ -176,110 +176,40 @@ describe('Search Sorting Picker', () => {
it('[C277280] Should be able to sort the search results by "Name" ASC', () => {
searchFilters.checkSearchFiltersIsDisplayed();
searchFilters.creatorCheckListFiltersPage().filterBy(`${acsUser.firstName} ${acsUser.lastName}`);
expect(searchResults.sortAndCheckListIsOrderedByName(true)).toBe(true);
searchResults.sortByName(true);
expect(searchResults.checkListIsOrderedByNameAsc()).toBe(true);
});
it('[C277281] Should be able to sort the search results by "Name" DESC', () => {
searchFilters.checkSearchFiltersIsDisplayed();
searchFilters.creatorCheckListFiltersPage().filterBy(`${acsUser.firstName} ${acsUser.lastName}`);
expect(searchResults.sortAndCheckListIsOrderedByName(false)).toBe(true);
searchResults.sortByName(false);
expect(searchResults.checkListIsOrderedByNameDesc()).toBe(true);
});
it('[C277282] Should be able to sort the search results by "Author" ASC', () => {
expect(searchResults.sortAndCheckListIsOrderedByAuthor(this.alfrescoJsApi, true)).toBe(true);
searchResults.sortByAuthor(true);
expect(searchResults.checkListIsOrderedByAuthorAsc()).toBe(true);
});
it('[C277283] Should be able to sort the search results by "Author" DESC', () => {
expect(searchResults.sortAndCheckListIsOrderedByAuthor(this.alfrescoJsApi, false)).toBe(true);
});
it('[C277284] Should be able to sort the search results by "Modifier" ASC', () => {
let searchConfiguration = new SearchConfiguration();
jsonFile = searchConfiguration.getConfiguration();
navigationBar.clickConfigEditorButton();
configEditor.clickSearchConfiguration();
configEditor.clickClearButton();
jsonFile.sorting.options.push({ 'key': 'Modifier', 'label': 'Modifier', 'type': 'FIELD', 'field': 'cm:modifier', 'ascending': true });
configEditor.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditor.clickSaveButton();
searchDialog.checkSearchIconIsVisible()
.clickOnSearchIcon()
.enterTextAndPressEnter(search);
searchSortingPicker.checkSortingSelectorIsDisplayed()
.sortBy(true, 'Modifier');
browser.controlFlow().execute(async () => {
let idList = await contentServices.getElementsDisplayedId();
let numberOfElements = await contentServices.numberOfResultsDisplayed();
let nodeList = await nodeActions.getNodesDisplayed(this.alfrescoJsApi, idList, numberOfElements);
let modifierList = [];
for (let i = 0; i < nodeList.length; i++) {
modifierList.push(nodeList[i].entry.modifiedByUser.id);
}
expect(contentServices.checkElementsSortedAsc(modifierList)).toBe(true);
});
});
it('[C277285] Should be able to sort the search results by "Modifier" DESC', () => {
let searchConfiguration = new SearchConfiguration();
jsonFile = searchConfiguration.getConfiguration();
navigationBar.clickConfigEditorButton();
configEditor.clickSearchConfiguration();
configEditor.clickClearButton();
jsonFile.sorting.options.push({ 'key': 'Modifier', 'label': 'Modifier', 'type': 'FIELD', 'field': 'cm:modifier', 'ascending': true });
configEditor.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditor.clickSaveButton();
searchDialog.checkSearchIconIsVisible()
.clickOnSearchIcon()
.enterTextAndPressEnter(search);
searchSortingPicker.checkSortingSelectorIsDisplayed()
.sortBy(false, 'Modifier');
browser.controlFlow().execute(async () => {
let idList = await contentServices.getElementsDisplayedId();
let numberOfElements = await contentServices.numberOfResultsDisplayed();
let nodeList = await nodeActions.getNodesDisplayed(this.alfrescoJsApi, idList, numberOfElements);
let modifierList = [];
for (let i = 0; i < nodeList.length; i++) {
modifierList.push(nodeList[i].entry.modifiedByUser.id);
}
expect(contentServices.checkElementsSortedDesc(modifierList)).toBe(true);
});
searchResults.sortByAuthor(false);
expect(searchResults.checkListIsOrderedByAuthorDesc()).toBe(true);
});
it('[C277286] Should be able to sort the search results by "Created Date" ASC', () => {
searchResults.sortByCreated(true);
browser.controlFlow().execute(async () => {
let idList = await contentServices.getElementsDisplayedId();
let numberOfElements = await contentServices.numberOfResultsDisplayed();
let nodeList = await nodeActions.getNodesDisplayed(this.alfrescoJsApi, idList, numberOfElements);
let dateList = [];
for (let i = 0; i < nodeList.length; i++) {
dateList.push(new Date(nodeList[i].entry.createdAt));
}
expect(contentServices.checkElementsSortedAsc(dateList)).toBe(true);
let results = await searchResults. dataTable.geCellElementDetail('Created');
expect(contentServices.checkElementsSortedAsc(results)).toBe(true);
});
});
it('[C277287] Should be able to sort the search results by "Created Date" DESC', () => {
searchResults.sortByCreated(false);
browser.controlFlow().execute(async () => {
let idList = await contentServices.getElementsDisplayedId();
let numberOfElements = await contentServices.numberOfResultsDisplayed();
let nodeList = await nodeActions.getNodesDisplayed(this.alfrescoJsApi, idList, numberOfElements);
let dateList = [];
for (let i = 0; i < nodeList.length; i++) {
dateList.push(new Date(nodeList[i].entry.createdAt));
}
expect(contentServices.checkElementsSortedDesc(dateList)).toBe(true);
let results = await searchResults. dataTable.geCellElementDetail('Created');
expect(contentServices.checkElementsSortedDesc(results)).toBe(true);
});
});
@@ -313,36 +243,6 @@ describe('Search Sorting Picker', () => {
});
});
it('[C277289] Should be able to sort the search results by "Modified Date" DESC', () => {
let searchConfiguration = new SearchConfiguration();
jsonFile = searchConfiguration.getConfiguration();
navigationBar.clickConfigEditorButton();
configEditor.clickSearchConfiguration();
configEditor.clickClearButton();
jsonFile.sorting.options.push({ 'key': 'Modified Date', 'label': 'Modified Date', 'type': 'FIELD', 'field': 'cm:modified', 'ascending': true });
configEditor.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditor.clickSaveButton();
searchDialog.checkSearchIconIsVisible()
.clickOnSearchIcon()
.enterTextAndPressEnter(search);
searchSortingPicker.checkSortingSelectorIsDisplayed()
.sortBy(false, 'Modified Date');
browser.controlFlow().execute(async () => {
let idList = await contentServices.getElementsDisplayedId();
let numberOfElements = await contentServices.numberOfResultsDisplayed();
let nodeList = await nodeActions.getNodesDisplayed(this.alfrescoJsApi, idList, numberOfElements);
let modifiedDateList = [];
for (let i = 0; i < nodeList.length; i++) {
modifiedDateList.push(new Date(nodeList[i].entry.modifiedAt));
}
expect(contentServices.checkElementsSortedAsc(modifiedDateList)).toBe(false);
});
});
it('[C277290] Should be able to sort the search results by "Size" ASC', () => {
searchResults.sortBySize(true);
expect(searchResults.checkListIsOrderedBySizeAsc()).toBe(true);
-95
View File
@@ -179,101 +179,6 @@ describe('Search component - Search Page', () => {
searchResultPage.checkNoResultMessageIsDisplayed();
});
describe('Sorting', () => {
beforeEach(() => {
searchDialog
.clickOnSearchIcon()
.enterTextAndPressEnter(search.active.base);
});
afterEach(async (done) => {
await browser.refresh();
done();
});
it('[C272803] Should be able to sort results by name (Ascending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByName(true).then((result) => {
expect(result).toEqual(true);
});
});
it('[C272804] Should be able to sort results by name (Descending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByName(false).then((result) => {
expect(result).toEqual(true);
});
});
it('[C272805] Should be able to sort results by author (Ascending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByAuthor(this.alfrescoJsApi, true).then((result) => {
expect(result).toEqual(true);
});
});
it('[C272806] Should be able to sort results by author (Descending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByAuthor(this.alfrescoJsApi, false).then((result) => {
expect(result).toEqual(true);
});
});
it('[C272807] Should be able to sort results by date (Ascending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByCreated(true).then((result) => {
expect(result).toEqual(true);
});
});
it('[C260260] Should be able to sort results by date (Descending)', () => {
searchResultPage.checkContentIsDisplayed(search.active.secondFile);
searchResultPage.sortAndCheckListIsOrderedByCreated(false).then((result) => {
expect(result).toEqual(true);
});
});
});
it('[C260262] Should not be able to delete a file from search results without rights', () => {
searchDialog
.clickOnSearchIcon()
.enterTextAndPressEnter(search.no_permission.noPermFile);
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFile);
searchResultPage.checkDeleteIsDisabled(search.no_permission.noPermFile);
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFile);
searchDialog.checkSearchBarIsNotVisible().checkSearchIconIsVisible().clickOnSearchIcon()
.enterTextAndPressEnter(search.no_permission.noPermFile);
searchResultPage.checkNoResultMessageIsNotDisplayed();
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFile);
});
it('[C272808] Should not be able to delete a folder from search results without rights', () => {
searchDialog
.clickOnSearchIcon()
.enterTextAndPressEnter(search.no_permission.noPermFolder);
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFolder);
searchResultPage.checkDeleteIsDisabled(search.no_permission.noPermFolder);
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFolder);
searchDialog
.clickOnSearchIcon()
.enterTextAndPressEnter(search.no_permission.noPermFolder);
searchResultPage.checkNoResultMessageIsNotDisplayed();
searchResultPage.checkContentIsDisplayed(search.no_permission.noPermFolder);
});
it('[C286675] Should display results when searching for all elements', () => {
searchDialog
.clickOnSearchIcon()