mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-4492] - Start restyling of search sorting (#2190)
* Started adding search sorting refactoring * [ACA-4492] - attempt to fix e2e with new sorting menu * [ACA-4436] - fixed linting * [ACA-4436] - fixed linting * fixed lint * [ACA-4492] - fixed e2e with new sorting * [ACA-4492] - fixed e2e with new sorting
This commit is contained in:
@@ -32,13 +32,13 @@ export type SortByType = 'Relevance' | 'Title' | 'Filename' | 'Modified date' |
|
||||
export type SortOrderType = 'ASC' | 'DESC' | '';
|
||||
|
||||
export class SearchSortingPicker extends Component {
|
||||
sortOrderButton = this.byCss('button[mat-icon-button]');
|
||||
sortByDropdownCollapsed = this.byCss('.mat-select');
|
||||
sortByDropdownExpanded = browser.element(by.css('.mat-select-panel'));
|
||||
sortByList = this.sortByDropdownExpanded.all(by.css('.mat-option .mat-option-text'));
|
||||
actionMenu = browser.element(by.css('aca-search-action-menu > button'));
|
||||
sortOrderButton = browser.element(by.css('#aca-button-sorting-menu'));
|
||||
sortByDropdownExpanded = browser.element.all(by.css('.mat-menu-panel')).get(1);
|
||||
sortByList = this.sortByDropdownExpanded.all(by.css('button'));
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super('adf-search-sorting-picker', ancestor);
|
||||
super('aca-button-action-menu', ancestor);
|
||||
}
|
||||
|
||||
async waitForSortByDropdownToExpand(): Promise<void> {
|
||||
@@ -50,35 +50,20 @@ export class SearchSortingPicker extends Component {
|
||||
}
|
||||
|
||||
async isSortOrderButtonDisplayed(): Promise<boolean> {
|
||||
return isPresentAndDisplayed(this.sortOrderButton);
|
||||
}
|
||||
|
||||
async getSortOrder(): Promise<SortOrderType> {
|
||||
const orderArrow = await this.sortOrderButton.getText();
|
||||
|
||||
if (orderArrow.includes('upward')) {
|
||||
return 'ASC';
|
||||
} else if (orderArrow.includes('downward')) {
|
||||
return 'DESC';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return isPresentAndDisplayed(this.actionMenu);
|
||||
}
|
||||
|
||||
async isSortByOptionDisplayed(): Promise<boolean> {
|
||||
return isPresentAndDisplayed(this.sortByDropdownCollapsed);
|
||||
return isPresentAndDisplayed(this.sortOrderButton);
|
||||
}
|
||||
|
||||
async isSortByDropdownExpanded(): Promise<boolean> {
|
||||
return isPresentAndDisplayed(this.sortByDropdownExpanded);
|
||||
}
|
||||
|
||||
async getSelectedSortByOption(): Promise<string> {
|
||||
return this.sortByDropdownCollapsed.getText();
|
||||
}
|
||||
|
||||
async clickSortByDropdown(): Promise<void> {
|
||||
await BrowserActions.click(this.sortByDropdownCollapsed);
|
||||
await BrowserActions.click(this.actionMenu);
|
||||
await BrowserActions.click(this.sortOrderButton);
|
||||
await this.waitForSortByDropdownToExpand();
|
||||
}
|
||||
|
||||
@@ -88,23 +73,14 @@ export class SearchSortingPicker extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
async sortBy(option: SortByType): Promise<void> {
|
||||
async sortBy(option: SortByType, direction: string): Promise<void> {
|
||||
if (!(await this.isSortByDropdownExpanded())) {
|
||||
await this.clickSortByDropdown();
|
||||
}
|
||||
const elem = browser.element(by.cssContainingText('.mat-option .mat-option-text', option));
|
||||
const elem = browser.element(by.cssContainingText('.mat-menu-item', option));
|
||||
const optionId = await elem.getAttribute('id');
|
||||
await BrowserActions.click(elem);
|
||||
}
|
||||
|
||||
async setSortOrderASC(): Promise<void> {
|
||||
if ((await this.getSortOrder()) !== 'ASC') {
|
||||
await BrowserActions.click(this.sortOrderButton);
|
||||
}
|
||||
}
|
||||
|
||||
async setSortOrderDESC(): Promise<void> {
|
||||
if ((await this.getSortOrder()) !== 'DESC') {
|
||||
await BrowserActions.click(this.sortOrderButton);
|
||||
}
|
||||
const directionSortElement = browser.element(by.id(`${optionId}-${direction.toLocaleLowerCase()}`));
|
||||
await BrowserActions.click(directionSortElement);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user