mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6239] Migrated personal files of pagination suit to playwright (#3528)
* [ACS-6239] Migrated personal files of pagination suit to playwright * [ACS-6239] Remove only * Added path in json file * [ACS-6239] Addressed review comments * [ACS-6239] Addressed review comments * [ACS-6239] Removed material classes and used roles for test cases * Addressed review comments
This commit is contained in:
@@ -23,8 +23,9 @@
|
||||
*/
|
||||
|
||||
import { BaseComponent } from './base.component';
|
||||
import { Page } from '@playwright/test';
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { MatMenuComponent } from './dataTable/mat-menu.component';
|
||||
import { timeouts } from '../../utils';
|
||||
|
||||
export enum PaginationActionsType {
|
||||
PageSizeSelector = 'Page size selector',
|
||||
@@ -39,6 +40,14 @@ export class PaginationComponent extends BaseComponent {
|
||||
super(page, PaginationComponent.rootElement);
|
||||
}
|
||||
|
||||
private range = this.getChild('.adf-pagination__range');
|
||||
private maxItems = this.getChild('.adf-pagination__max-items');
|
||||
private currentPage = this.getChild('.adf-pagination__current-page');
|
||||
private totalPages = this.getChild('.adf-pagination__total-pages');
|
||||
private previousButton = this.getChild('.adf-pagination__previous-button');
|
||||
private nextButton = this.getChild('.adf-pagination__next-button');
|
||||
private maxItemsButton = this.getChild('.adf-pagination__max-items + button[mat-icon-button]');
|
||||
|
||||
private itemsPerPageMenu = new MatMenuComponent(this.page);
|
||||
|
||||
public currentPageLocator = this.getChild('.adf-pagination__current-page');
|
||||
@@ -65,4 +74,92 @@ export class PaginationComponent extends BaseComponent {
|
||||
this.logger.info('Spinner was not present');
|
||||
}
|
||||
}
|
||||
|
||||
async getRange(): Promise<string> {
|
||||
return this.range.innerText();
|
||||
}
|
||||
|
||||
async getMaxItems(): Promise<string> {
|
||||
return this.maxItems.innerText();
|
||||
}
|
||||
|
||||
async getCurrentPage(): Promise<string> {
|
||||
return this.currentPage.innerText();
|
||||
}
|
||||
|
||||
async getTotalPages(): Promise<string> {
|
||||
return this.totalPages.innerText();
|
||||
}
|
||||
|
||||
async isPreviousEnabled(): Promise<boolean> {
|
||||
return this.previousButton.isEnabled();
|
||||
}
|
||||
|
||||
async isNextEnabled(): Promise<boolean> {
|
||||
await this.page.waitForTimeout(timeouts.tiny);
|
||||
return this.nextButton.isEnabled();
|
||||
}
|
||||
|
||||
async clickOnNextPage(): Promise<void> {
|
||||
try {
|
||||
if (await this.isNextEnabled()) {
|
||||
await this.nextButton.click();
|
||||
}
|
||||
} catch(error) {
|
||||
throw new Error(`Failed on previous click: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async clickOnPreviousPage(): Promise<void> {
|
||||
try {
|
||||
if (await this.isPreviousEnabled()) {
|
||||
await this.previousButton.click();
|
||||
}
|
||||
} catch(error) {
|
||||
throw new Error(`Failed on previous click: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async openMaxItemsMenu(): Promise<void> {
|
||||
try {
|
||||
await this.maxItemsButton.waitFor({ state: 'visible' });
|
||||
await this.maxItemsButton.click();
|
||||
} catch (error) {
|
||||
throw new Error(`Open max items catch: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async resetToDefaultPageSize(): Promise<void> {
|
||||
try {
|
||||
await this.openMaxItemsMenu();
|
||||
await this.clickNthItem(1);
|
||||
await this.page.waitForTimeout(timeouts.tiny);
|
||||
} catch (error) {
|
||||
throw new Error(`Reset to default page size catch: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async clickMenuItem(menuItem: string): Promise<void> {
|
||||
try {
|
||||
await this.page.getByRole('menuitem', { name: menuItem }).click();
|
||||
} catch (e) {
|
||||
throw new Error(`Click menu item catch : failed to click on: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
async getNthItem(nth: number): Promise<Locator> {
|
||||
return this.page.getByRole('menuitem').nth(nth - 1);
|
||||
}
|
||||
|
||||
async getItemsCount(): Promise<number> {
|
||||
return await this.page.getByRole('menuitem').count();
|
||||
}
|
||||
|
||||
async clickNthItem(nth: number): Promise<void> {
|
||||
try {
|
||||
await (await this.getNthItem(nth)).click();
|
||||
} catch (e) {
|
||||
throw new Error(`Click nth menu item catch: ${e}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user