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,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { NodeChildAssociationPaging, NodeEntry } from '@alfresco/js-api';
|
||||
import { NodeChildAssociationPaging, NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
|
||||
|
||||
@@ -73,6 +73,15 @@ export class NodesApi {
|
||||
}
|
||||
}
|
||||
|
||||
async createFiles(names: string[], relativePath = '/'): Promise<NodePaging> {
|
||||
try {
|
||||
return await this.createContent({ files: names }, relativePath);
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.createFiles.name}: ${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async createNode(
|
||||
nodeType: string,
|
||||
name: string,
|
||||
@@ -137,9 +146,9 @@ export class NodesApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all nodes of the currently logged in user
|
||||
* @param userNodeId The id of User node, all child nodes of "userNodeId" will be gathered as a list and deleted ( e.g.: "-my-" - User Homes folder)
|
||||
*/
|
||||
* Delete all nodes of the currently logged in user
|
||||
* @param userNodeId The id of User node, all child nodes of "userNodeId" will be gathered as a list and deleted ( e.g.: "-my-" - User Homes folder)
|
||||
*/
|
||||
async deleteCurrentUserNodes(): Promise<void> {
|
||||
try {
|
||||
const userNodes = (await this.getNodeChildren('-my-')).list.entries;
|
||||
@@ -160,11 +169,12 @@ export class NodesApi {
|
||||
}
|
||||
}
|
||||
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodeEntry | any> {
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodePaging> {
|
||||
try {
|
||||
return await this.apiService.nodes.createNode('-my-', flattenNodeContentTree(content, relativePath) as any);
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.createContent.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,11 +260,10 @@ export class NodesApi {
|
||||
}
|
||||
|
||||
private async getDataDictionaryId(): Promise<string> {
|
||||
return this.getNodeIdFromParent('Data Dictionary', '-root-')
|
||||
.catch((error) => {
|
||||
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
|
||||
return '';
|
||||
});
|
||||
return this.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => {
|
||||
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {
|
||||
|
@@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,8 @@ import {
|
||||
DataTableComponent,
|
||||
MatMenuComponent,
|
||||
ViewerComponent,
|
||||
SidenavComponent
|
||||
SidenavComponent,
|
||||
PaginationComponent
|
||||
} from '../components';
|
||||
|
||||
export class PersonalFilesPage extends BasePage {
|
||||
@@ -56,9 +57,18 @@ export class PersonalFilesPage extends BasePage {
|
||||
public breadcrumb = new Breadcrumb(this.page);
|
||||
public sidenav = new SidenavComponent(this.page);
|
||||
public createFromTemplateDialogComponent = new CreateFromTemplateDialogComponent(this.page);
|
||||
public pagination = new PaginationComponent(this.page);
|
||||
|
||||
async selectCreateFolder(): Promise<void> {
|
||||
await this.acaHeader.createButton.click();
|
||||
await this.matMenu.createFolder.click();
|
||||
}
|
||||
|
||||
async closeMenu(): Promise<void> {
|
||||
await this.page.keyboard.press('Escape');
|
||||
}
|
||||
|
||||
async waitForPageLoad() {
|
||||
await this.page.waitForURL(`**/${PersonalFilesPage.pageUrl}`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user