[ADF-3644] Automated test for search filters collapse (#3889)

* [ADF-3644] Automated test for search filters collapse

* Changing selectors

* Fixing [C277146] and changing methods in searchFiltersPage
This commit is contained in:
Marouan Bentaleb
2018-10-24 19:06:30 +01:00
committed by Eugenio Romano
parent 858584bcf0
commit 36a150af4f
2 changed files with 62 additions and 35 deletions

View File

@@ -91,13 +91,27 @@ describe('Search Filters', () => {
it('[C277146] Should Show more/less buttons be hidden when inactive', () => { it('[C277146] Should Show more/less buttons be hidden when inactive', () => {
browser.get(TestConfig.adf.url + '/search;q=*'); browser.get(TestConfig.adf.url + '/search;q=*');
searchFiltersPage.checkShowLessButtonIsNotDisplayed(); searchFiltersPage.checkCreatedShowLessButtonIsNotDisplayed();
searchFiltersPage.checkSizeShowMoreButtonIsDisplayed(); searchFiltersPage.checkCreatedShowMoreButtonIsDisplayed();
searchFiltersPage.clickSizeShowMoreButtonUntilIsNotDisplayed(); searchFiltersPage.clickCreatedShowMoreButtonUntilIsNotDisplayed();
searchFiltersPage.checkShowLessButtonIsDisplayed(); searchFiltersPage.checkCreatedShowLessButtonIsDisplayed();
searchFiltersPage.clickSizeShowLessButtonUntilIsNotDisplayed(); searchFiltersPage.clickCreatedShowLessButtonUntilIsNotDisplayed();
});
it('[C286556] Search categories should preserve their collapsed/expanded state after the search', () => {
browser.get(TestConfig.adf.url + '/search;q=*');
searchFiltersPage.clickFileTypeFilterHeader();
searchFiltersPage.checkFileTypeFilterIsCollapsed();
searchFiltersPage.clickFileSizeFilterHeader();
searchFiltersPage.checkFileSizeFilterIsCollapsed();
searchFiltersPage.selectCreator('Administrator');
searchFiltersPage.checkFileTypeFilterIsCollapsed();
searchFiltersPage.checkFileSizeFilterIsCollapsed();
}); });
}); });

View File

@@ -26,9 +26,9 @@ export class SearchFiltersPage {
creatorFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.CREATOR"]')); creatorFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.CREATOR"]'));
searchCreatorFilter = element(by.css('input[data-automation-id="facet-result-filter-SEARCH.FACET_FIELDS.CREATOR"]')); searchCreatorFilter = element(by.css('input[data-automation-id="facet-result-filter-SEARCH.FACET_FIELDS.CREATOR"]'));
fileSizeFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.SIZE"]')); fileSizeFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.SIZE"]'));
showMoreButtonForSize = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.SIZE"] button[title="Show more"]')); createdFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.CREATED"'));
showLessButtonForSize = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-SEARCH.FACET_FIELDS.SIZE"] button[title="Show less"]')); showMoreButtonForCreated = this.createdFilter.element(by.css('button[title="Show more"]'));
numberOfCheckboxesForSize = element.all(by.css('mat-checkbox[data-automation-id*="checkbox-SEARCH.FACET_FIELDS.SIZE"]')); showLessButtonForCreated = this.createdFilter.element(by.css('button[title="Show less"]'));
checkSearchFiltersIsDisplayed() { checkSearchFiltersIsDisplayed() {
Util.waitUntilElementIsVisible(this.searchFilters); Util.waitUntilElementIsVisible(this.searchFilters);
@@ -74,6 +74,30 @@ export class SearchFiltersPage {
result.click(); result.click();
} }
clickFileSizeFilterHeader() {
let fileSizeFilterHeader = this.fileSizeFilter.element(by.css('mat-expansion-panel-header'));
Util.waitUntilElementIsClickable(fileSizeFilterHeader);
return fileSizeFilterHeader.click();
}
clickFileTypeFilterHeader() {
let fileTypeFilterHeader = this.fileTypeFilter.element(by.css('mat-expansion-panel-header'));
Util.waitUntilElementIsClickable(fileTypeFilterHeader);
return fileTypeFilterHeader.click();
}
checkFileTypeFilterIsCollapsed() {
this.fileTypeFilter.getAttribute('class').then((elementClass) => {
expect(elementClass).not.toContain('mat-expanded');
});
}
checkFileSizeFilterIsCollapsed() {
this.fileSizeFilter.getAttribute('class').then((elementClass) => {
expect(elementClass).not.toContain('mat-expanded');
});
}
filterByFileType(fileType) { filterByFileType(fileType) {
this.checkFileTypeFilterIsDisplayed(); this.checkFileTypeFilterIsDisplayed();
@@ -104,53 +128,42 @@ export class SearchFiltersPage {
return Util.waitUntilElementIsNotOnPage(element(by.cssContainingText('mat-chip', ` ${creatorFirstName} ${creatorLastName} `)).element(by.css('mat-icon'))); return Util.waitUntilElementIsNotOnPage(element(by.cssContainingText('mat-chip', ` ${creatorFirstName} ${creatorLastName} `)).element(by.css('mat-icon')));
} }
clickSizeShowMoreButtonUntilIsNotDisplayed() { clickCreatedShowMoreButtonUntilIsNotDisplayed() {
Util.waitUntilElementIsVisible(this.fileSizeFilter); Util.waitUntilElementIsVisible(this.createdFilter);
this.showMoreButtonForSize.isDisplayed().then(async (visible) => { this.showMoreButtonForCreated.isDisplayed().then(async (visible) => {
if (visible) { if (visible) {
for (let checkboxes = 5; checkboxes <= totalNumberOfCheckboxes; checkboxes + 5) { this.showMoreButtonForCreated.click();
let totalNumberOfCheckboxes = await numberOfCheckboxesForSize.count();
expect(totalNumberOfCheckboxes).toEqual(checkboxes); this.clickCreatedShowMoreButtonUntilIsNotDisplayed();
}
this.showMoreButtonForSize.click();
this.clickSizeShowMoreButtonUntilIsNotDisplayed();
} }
}, err => { }, err => {
}); });
} }
checkSizeShowMoreButtonIsDisplayed() { checkCreatedShowMoreButtonIsDisplayed() {
Util.waitUntilElementIsVisible(this.showMoreButtonForSize); Util.waitUntilElementIsVisible(this.showMoreButtonForCreated);
} }
clickSizeShowLessButtonUntilIsNotDisplayed() { clickCreatedShowLessButtonUntilIsNotDisplayed() {
Util.waitUntilElementIsVisible(this.fileSizeFilter); Util.waitUntilElementIsVisible(this.createdFilter);
this.showLessButtonForSize.isDisplayed().then(async (visible) => { this.showLessButtonForCreated.isDisplayed().then(async (visible) => {
if (visible) { if (visible) {
let totalNumberOfCheckboxes = await this.numberOfCheckboxesForSize.count(); this.showLessButtonForCreated.click();
for (let checkboxes = totalNumberOfCheckboxes; checkboxes > 10; checkboxes = totalNumberOfCheckboxes - checkboxes) { this.clickCreatedShowLessButtonUntilIsNotDisplayed();
expect(totalNumberOfCheckboxes).toEqual(checkboxes);
}
this.showLessButtonForSize.click();
this.clickSizeShowLessButtonUntilIsNotDisplayed();
} }
}, err => { }, err => {
}); });
} }
checkShowLessButtonIsNotDisplayed() { checkCreatedShowLessButtonIsNotDisplayed() {
Util.waitUntilElementIsNotVisible(this.showLessButtonForSize); Util.waitUntilElementIsNotVisible(this.showLessButtonForCreated);
} }
checkShowLessButtonIsDisplayed() { checkCreatedShowLessButtonIsDisplayed() {
Util.waitUntilElementIsVisible(this.showLessButtonForSize); Util.waitUntilElementIsVisible(this.showLessButtonForCreated);
} }
} }