-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
e2e/playwright/shared/page-objects/components/mat-menu.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright © 2005 - 2023 Alfresco Software, Ltd. All rights reserved. | ||
* | ||
* License rights for this program may be obtained from Alfresco Software, Ltd. | ||
* pursuant to a written agreement and any use of this program without such an | ||
* agreement is prohibited. | ||
*/ | ||
|
||
import { Page } from '@playwright/test'; | ||
import { BaseComponent } from './base.component'; | ||
|
||
export class MatMenuComponent extends BaseComponent { | ||
private static rootElement = '.mat-menu-content'; | ||
|
||
constructor(page: Page) { | ||
super(page, MatMenuComponent.rootElement); | ||
} | ||
|
||
public getMenuItemsLocator = this.getChild('button'); | ||
public getMenuItemTextLocator = this.getChild('[data-automation-id="menu-item-title"]'); | ||
|
||
public getButtonByText = (text: string) => this.getChild('button', { hasText: text }); | ||
} |
52 changes: 52 additions & 0 deletions
52
e2e/playwright/shared/page-objects/components/pagination.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright © 2005 - 2023 Alfresco Software, Ltd. All rights reserved. | ||
* | ||
* License rights for this program may be obtained from Alfresco Software, Ltd. | ||
* pursuant to a written agreement and any use of this program without such an | ||
* agreement is prohibited. | ||
*/ | ||
|
||
import { BaseComponent } from './base.component'; | ||
import { Page } from '@playwright/test'; | ||
import { MatMenuComponent } from './mat-menu.component'; | ||
|
||
export enum PaginationActionsType { | ||
PageSizeSelector = 'Page size selector', | ||
CurrentPageSelector = 'Current page selector', | ||
NextPageSelector = 'Next page button' | ||
} | ||
|
||
export class PaginationComponent extends BaseComponent { | ||
private static rootElement = 'adf-pagination'; | ||
|
||
constructor(page: Page) { | ||
super(page, PaginationComponent.rootElement); | ||
} | ||
|
||
private itemsPerPageMenu = new MatMenuComponent(this.page); | ||
|
||
public currentPageLocator = this.getChild('.adf-pagination__current-page'); | ||
public totalPageLocator = this.getChild('.adf-pagination__total-pages'); | ||
public getArrowLocatorFor = (action: PaginationActionsType) => this.getChild(`[aria-label="${action}"]`); | ||
|
||
async setItemsPerPage(amount: number): Promise<void> { | ||
await this.getArrowLocatorFor(PaginationActionsType.PageSizeSelector).click(); | ||
await this.itemsPerPageMenu.getButtonByText(amount.toString()).click(); | ||
await this.spinnerWaitForReload(); | ||
} | ||
|
||
async navigateToPage(pageNumber: number): Promise<void> { | ||
await this.getArrowLocatorFor(PaginationActionsType.CurrentPageSelector).click(); | ||
await this.itemsPerPageMenu.getButtonByText(pageNumber.toString()).click(); | ||
await this.spinnerWaitForReload(); | ||
} | ||
|
||
async spinnerWaitForReload(): Promise<void> { | ||
try { | ||
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: 2000 }); | ||
await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: 2000 }); | ||
} catch (e) { | ||
this.logger.info('Spinner was not present'); | ||
} | ||
} | ||
} |