[ACS-6799] Search sorting tests migrated to Playwright (#3705)

* [ACS-6799] search sorting migrated to Playwright

* [ACS-6799] review fixes 1

* [ACS-6799] cloudflare fix 1

* [ACS-6799] cloudflare fix 2

* [ACS-6799] review fixed 2

* [ACS-6799] sonarcloud fix 3
This commit is contained in:
Adam Świderski
2024-03-14 12:13:03 +01:00
committed by GitHub
parent e54854e052
commit 8512e42ece
10 changed files with 275 additions and 777 deletions

View File

@@ -78,6 +78,13 @@ export class DataTableComponent extends BaseComponent {
getRowByColumnTitleAndItsCellValue = (columnTitle: string, cellValue: string | number): Locator =>
this.page.locator(`//div[contains(@title, '${columnTitle}')]//span[contains(text(), '${cellValue}')]/ancestor::adf-datatable-row`);
/**
* Method used in cases where we want to retrieve a row from the datatable based on its numerical order within the array.
*
* @returns reference to cell element which contains text.
*/
getNthRow = (orderNum: number): Locator => this.getRowLocator.nth(orderNum);
/**
* Method used in cases where user have possibility to navigate "inside" the element (it's clickable and has link attribute).
* Perform action .click() to navigate inside it

View File

@@ -35,6 +35,7 @@ export * from './adf-info-drawer.component';
export * from './viewer.component';
export * from './search/search-input.component';
export * from './search/search-overlay.components';
export * from './search/search-sorting-picker.components';
export * from './breadcrumb/breadcrumb.component';
export * from './sidenav.component';
export * from './aca-header.component';

View File

@@ -0,0 +1,85 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Page } from '@playwright/test';
import { BaseComponent } from '../base.component';
export type SortByType = 'Relevance' | 'Title' | 'Filename' | 'Modified date' | 'Modifier' | 'Created date' | 'Size' | 'Type';
export type SortByDirection = 'asc' | 'desc';
export class SearchSortingPicker extends BaseComponent {
private static rootElement = '#aca-button-action-menu';
public actionMenu = this.page.locator('[data-automation-id="auto_header_content_id_$thumbnail"]');
public sortOrderButton = this.page.locator('#aca-button-sorting-menu');
public sortByDropdownExpanded = this.page.locator('.mat-menu-panel').first();
public sortByList = this.page.locator('.mat-menu-panel button');
constructor(page: Page, rootElement = SearchSortingPicker.rootElement) {
super(page, rootElement);
}
async waitForSortByDropdownToExpand(): Promise<void> {
await this.sortByDropdownExpanded.waitFor();
}
async isSortOrderButtonDisplayed(): Promise<boolean> {
return this.sortOrderButton.isVisible();
}
async isSortByDropdownExpanded(): Promise<boolean> {
return this.sortByDropdownExpanded.isVisible();
}
async clickSortByDropdown(): Promise<void> {
await this.sortOrderButton.click();
await this.waitForSortByDropdownToExpand();
}
async getSortByOptionsList(): Promise<string[]> {
let sortOptionsCount = await this.sortByList.count();
let sortByOptions: string[] = [];
for (let i = 1; i < sortOptionsCount; i++) {
let textContent = (await this.sortByList.nth(i).textContent()).trim();
sortByOptions.push(textContent);
}
sortByOptions.sort((a, b) => a.localeCompare(b));
return sortByOptions;
}
async sortBy(option: SortByType, direction: SortByDirection): Promise<void> {
await this.actionMenu.click();
await this.clickSortByDropdown();
if (!(await this.isSortByDropdownExpanded())) {
await this.clickSortByDropdown();
}
const elem = this.sortByList.getByText(option);
const optionId = await elem.getAttribute('id');
await elem.click();
const directionSortElement = this.page.locator(`[id="${optionId}-${direction.toLocaleLowerCase()}"]`);
await directionSortElement.click();
await this.progressBarWaitForReload();
}
}

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent, SidenavComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent, SidenavComponent, SearchSortingPicker } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfConfirmDialogComponent, AdfFolderDialogComponent } from '../components/dialogs';
@@ -44,6 +44,7 @@ export class SearchPage extends BasePage {
public viewer = new ViewerComponent(this.page);
public searchInput = new SearchInputComponent(this.page);
public searchOverlay = new SearchOverlayComponent(this.page);
public searchSortingPicker = new SearchSortingPicker(this.page);
public sidenav = new SidenavComponent(this.page);
public confirmDialogComponent = new AdfConfirmDialogComponent(this.page);