diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 9b3dc87f3d..1b81df3c9d 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -182,6 +182,8 @@ jobs:
id: 5
- name: "special-permissions"
id: 6
+ - name: "pagination"
+ id: 7
steps:
- name: Checkout
uses: actions/checkout@v3
diff --git a/e2e/playwright/pagination/.eslintrc.json b/e2e/playwright/pagination/.eslintrc.json
new file mode 100644
index 0000000000..9bacf995fe
--- /dev/null
+++ b/e2e/playwright/pagination/.eslintrc.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../../.eslintrc.json",
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts"],
+ "parserOptions": {
+ "project": ["e2e/playwright/pagination/tsconfig.e2e.json"],
+ "createDefaultProgram": true
+ },
+ "plugins": ["rxjs", "unicorn"],
+ "rules": {
+ "@typescript-eslint/no-floating-promises": "off"
+ }
+ }
+ ]
+}
diff --git a/e2e/playwright/pagination/exclude.tests.json b/e2e/playwright/pagination/exclude.tests.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/e2e/playwright/pagination/exclude.tests.json
@@ -0,0 +1 @@
+{}
diff --git a/e2e/playwright/pagination/playwright.config.ts b/e2e/playwright/pagination/playwright.config.ts
new file mode 100644
index 0000000000..c6e0c03fc4
--- /dev/null
+++ b/e2e/playwright/pagination/playwright.config.ts
@@ -0,0 +1,44 @@
+/*!
+ * 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
+ * from Hyland Software. If not, see .
+ */
+
+import { PlaywrightTestConfig } from '@playwright/test';
+import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared';
+import EXCLUDED_JSON from './exclude.tests.json';
+
+const config: PlaywrightTestConfig = {
+ ...getGlobalConfig,
+
+ grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Pagination'),
+ projects: [
+ {
+ name: 'Pagination',
+ testDir: './src/tests/',
+ use: {
+ users: ['hruser']
+ }
+ }
+ ]
+};
+
+export default config;
diff --git a/e2e/playwright/pagination/project.json b/e2e/playwright/pagination/project.json
new file mode 100644
index 0000000000..6d28ddc609
--- /dev/null
+++ b/e2e/playwright/pagination/project.json
@@ -0,0 +1,22 @@
+{
+ "name": "pagination-e2e",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "e2e/playwright/pagination/src",
+ "projectType": "application",
+ "targets": {
+ "e2e": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": ["npx playwright test --config=e2e/playwright/pagination/playwright.config.ts"]
+ },
+ "configurations": {
+ "production": {
+ "devServerTarget": "content-ce:serve:production"
+ }
+ }
+ },
+ "lint": {
+ "executor": "@angular-eslint/builder:lint"
+ }
+ }
+}
diff --git a/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts b/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts
new file mode 100755
index 0000000000..816ab3ff83
--- /dev/null
+++ b/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts
@@ -0,0 +1,57 @@
+/*!
+ * 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
+ * from Hyland Software. If not, see .
+ */
+
+import { ApiClientFactory, NodesApi, test, Utils } from '@alfresco/playwright-shared';
+import { personalFilesTests } from './personal-files';
+
+test.describe('Pagination on multiple pages : ', () => {
+ const random = Utils.random();
+ const username = `user-${random}`;
+
+ const parent = `parent-${random}`;
+ let parentId: string;
+
+ const apiClientFactory = new ApiClientFactory();
+
+ test.beforeAll(async () => {
+ await apiClientFactory.setUpAcaBackend('admin');
+ await apiClientFactory.createUser({ username });
+ const nodesApi = await NodesApi.initialize(username, username);
+
+ const files = Array(51)
+ .fill('my-file')
+ .map((name, index): string => `${name}-${index + 1}-${random}.txt`);
+
+ parentId = (await nodesApi.createFolder(parent)).entry.id;
+ (await nodesApi.createFiles(files, parent)).list.entries.map((entries) => entries.entry.id);
+ });
+
+ test.afterAll(async () => {
+ await apiClientFactory.nodes.deleteNode(parentId, { permanent: true });
+ });
+
+ test.describe('on Personal Files', () => {
+ personalFilesTests(username, parent);
+ });
+});
diff --git a/e2e/playwright/pagination/src/tests/personal-files.ts b/e2e/playwright/pagination/src/tests/personal-files.ts
new file mode 100644
index 0000000000..c1b4d05c80
--- /dev/null
+++ b/e2e/playwright/pagination/src/tests/personal-files.ts
@@ -0,0 +1,107 @@
+/*!
+ * 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
+ * from Hyland Software. If not, see .
+ */
+
+import { test, timeouts } from '@alfresco/playwright-shared';
+import { expect } from '@playwright/test';
+
+export function personalFilesTests(userName: string, parentName: string) {
+ test.describe('Pagination controls : ', () => {
+ test.beforeEach(async ({ loginPage, personalFiles, page }) => {
+ await loginPage.navigate();
+ await loginPage.loginUser({ username: userName, password: userName });
+ await personalFiles.waitForPageLoad();
+ await personalFiles.dataTable.getRowByName(parentName).dblclick();
+ await page.waitForTimeout(timeouts.tiny);
+ });
+
+ test('[C280077] Pagination control default values', async ({ personalFiles }) => {
+ expect(await personalFiles.pagination.getRange()).toContain('Showing 1-25 of 51');
+ expect(await personalFiles.pagination.getMaxItems()).toContain('25');
+ expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
+ expect(await personalFiles.pagination.getTotalPages()).toContain('of 3');
+ expect(await personalFiles.pagination.isPreviousEnabled()).toBe(false);
+ expect(await personalFiles.pagination.isNextEnabled()).toBe(true);
+ });
+
+ test('[C280078] Items per page values', async ({ personalFiles }) => {
+ await personalFiles.pagination.openMaxItemsMenu();
+ expect(await (await personalFiles.pagination.getNthItem(1)).innerText()).toBe('25');
+ expect(await (await personalFiles.pagination.getNthItem(2)).innerText()).toBe('50');
+ expect(await (await personalFiles.pagination.getNthItem(3)).innerText()).toBe('100');
+ await personalFiles.closeMenu();
+ });
+
+ test('[C280079] current page menu items', async ({ personalFiles }) => {
+ await personalFiles.pagination.openMaxItemsMenu();
+ await personalFiles.pagination.clickMenuItem('25');
+ expect(await personalFiles.pagination.getMaxItems()).toContain('25');
+ expect(await personalFiles.pagination.getTotalPages()).toContain('of 3');
+ expect(await personalFiles.pagination.getItemsCount()).toBe(3);
+
+ await personalFiles.pagination.openMaxItemsMenu();
+ await personalFiles.pagination.clickMenuItem('50');
+ expect(await personalFiles.pagination.getMaxItems()).toContain('50');
+ expect(await personalFiles.pagination.getTotalPages()).toContain('of 2');
+
+ await personalFiles.pagination.openMaxItemsMenu();
+ await personalFiles.pagination.clickMenuItem('100');
+ expect(await personalFiles.pagination.getMaxItems()).toContain('100');
+ expect(await personalFiles.pagination.getTotalPages()).toContain('of 1');
+
+ await personalFiles.pagination.resetToDefaultPageSize();
+ });
+
+ test('[C280080] change the current page from menu', async ({ personalFiles }) => {
+ await personalFiles.pagination.clickOnNextPage();
+ expect(await personalFiles.pagination.getRange()).toContain('Showing 26-50 of 51');
+ expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 2');
+ expect(await personalFiles.pagination.isPreviousEnabled()).toBe(true);
+ expect(await personalFiles.pagination.isNextEnabled()).toBe(true);
+ await personalFiles.pagination.resetToDefaultPageSize();
+ });
+
+ test('[C280083] navigate to next and previous pages', async ({ personalFiles }) => {
+ await personalFiles.pagination.openMaxItemsMenu();
+ await personalFiles.pagination.clickMenuItem('25');
+ expect(await personalFiles.pagination.getMaxItems()).toContain('25');
+ await personalFiles.pagination.clickOnNextPage();
+ expect(await personalFiles.pagination.getRange()).toContain('Showing 26-50 of 51');
+
+ await personalFiles.pagination.clickOnPreviousPage();
+ expect(await personalFiles.pagination.getRange()).toContain('Showing 1-25 of 51');
+ });
+
+ test('[C280081] Previous button is disabled on first page', async ({ personalFiles }) => {
+ expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
+ expect(await personalFiles.pagination.isPreviousEnabled()).toBe(false);
+ });
+
+ test('[C280082] Next button is disabled on last page', async ({ personalFiles }) => {
+ await personalFiles.pagination.openMaxItemsMenu();
+ await personalFiles.pagination.clickNthItem(3);
+ expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
+ expect(await personalFiles.pagination.isNextEnabled()).toBe(false);
+ });
+ });
+}
diff --git a/e2e/playwright/pagination/tsconfig.e2e.adf.json b/e2e/playwright/pagination/tsconfig.e2e.adf.json
new file mode 100644
index 0000000000..87cbcf775a
--- /dev/null
+++ b/e2e/playwright/pagination/tsconfig.e2e.adf.json
@@ -0,0 +1,15 @@
+{
+ "extends": "../../../tsconfig.adf.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/e2e",
+ "baseUrl": "./",
+ "module": "commonjs",
+ "target": "es2017",
+ "types": ["jasmine", "jasminewd2", "node"],
+ "skipLibCheck": true,
+ "paths": {
+ "@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
+ }
+ },
+ "exclude": ["node_modules"]
+}
diff --git a/e2e/playwright/pagination/tsconfig.e2e.json b/e2e/playwright/pagination/tsconfig.e2e.json
new file mode 100755
index 0000000000..c317985239
--- /dev/null
+++ b/e2e/playwright/pagination/tsconfig.e2e.json
@@ -0,0 +1,15 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/e2e",
+ "baseUrl": "./",
+ "module": "commonjs",
+ "target": "es2017",
+ "types": ["jasmine", "jasminewd2", "node", "@playwright/test"],
+ "skipLibCheck": true,
+ "paths": {
+ "@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
+ }
+ },
+ "exclude": ["node_modules"]
+}
diff --git a/e2e/protractor/suites/pagination/multiple-pages-files.test.ts b/e2e/protractor/suites/pagination/multiple-pages-files.test.ts
index 82e2a8afca..d26b9c6f49 100644
--- a/e2e/protractor/suites/pagination/multiple-pages-files.test.ts
+++ b/e2e/protractor/suites/pagination/multiple-pages-files.test.ts
@@ -23,7 +23,6 @@
*/
import { Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared';
-import { personalFilesTests } from './personal-files';
import { recentFilesTests } from './recent-files';
import { searchResultsTests } from './search-results';
import { sharedFilesTests } from './shared-files';
@@ -64,10 +63,6 @@ describe('Pagination on multiple pages : ', () => {
await userApi.nodes.deleteNodeById(parentId);
});
- describe('on Personal Files', () => {
- personalFilesTests(username, parent);
- });
-
describe('on Recent Files', () => {
beforeAll(async () => {
await userApi.search.waitForApi(username, { expect: initialSearchTotalItems + 51 });
diff --git a/e2e/protractor/suites/pagination/personal-files.ts b/e2e/protractor/suites/pagination/personal-files.ts
deleted file mode 100755
index 078d451a53..0000000000
--- a/e2e/protractor/suites/pagination/personal-files.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-/*!
- * 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
- * from Hyland Software. If not, see .
- */
-
-import { BrowsingPage, LoginPage, Utils } from '@alfresco/aca-testing-shared';
-
-export function personalFilesTests(username: string, parentName: string) {
- const page = new BrowsingPage();
- const loginPage = new LoginPage();
- const { dataTable, pagination } = page;
-
- describe('Pagination controls : ', () => {
- beforeAll(async () => {
- await loginPage.loginWith(username);
- await page.clickPersonalFilesAndWait();
- await dataTable.doubleClickOnRowByName(parentName);
- await dataTable.waitForHeader();
- });
-
- afterEach(async () => {
- await Utils.pressEscape();
- });
-
- it('[C280077] Pagination control default values', async () => {
- expect(await pagination.getRange()).toContain('1-25 of 51');
- expect(await pagination.getMaxItems()).toContain('25');
- expect(await pagination.getCurrentPage()).toContain('Page 1');
- expect(await pagination.getTotalPages()).toContain('of 3');
- expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled');
- expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
- });
-
- it('[C280078] Items per page values', async () => {
- await pagination.openMaxItemsMenu();
- expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
- expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
- expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
- await pagination.menu.closeMenu();
- });
-
- it('[C280079] current page menu items', async () => {
- await pagination.openMaxItemsMenu();
- await pagination.menu.clickMenuItem('25');
- expect(await pagination.getMaxItems()).toContain('25');
- expect(await pagination.getTotalPages()).toContain('of 3');
- await pagination.openCurrentPageMenu();
- expect(await pagination.menu.getItemsCount()).toBe(3);
- await pagination.menu.closeMenu();
-
- await pagination.openMaxItemsMenu();
- await pagination.menu.clickMenuItem('50');
- expect(await pagination.getMaxItems()).toContain('50');
- expect(await pagination.getTotalPages()).toContain('of 2');
- await pagination.openCurrentPageMenu();
- expect(await pagination.menu.getItemsCount()).toBe(2);
- await pagination.menu.closeMenu();
-
- await pagination.openMaxItemsMenu();
- await pagination.menu.clickMenuItem('100');
- expect(await pagination.getMaxItems()).toContain('100');
- expect(await pagination.getTotalPages()).toContain('of 1');
-
- await pagination.resetToDefaultPageSize();
- });
-
- it('[C280080] change the current page from menu', async () => {
- await pagination.openCurrentPageMenu();
- await pagination.menu.clickNthItem(3);
- await dataTable.waitForHeader();
- expect(await pagination.getRange()).toContain('51-51 of 51');
- expect(await pagination.getCurrentPage()).toContain('Page 3');
- expect(await pagination.isPreviousEnabled()).toBe(true, 'Previous button is not enabled');
- expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled');
- expect(await dataTable.isItemPresent('my-file-9')).toBe(true, 'File not found on page');
-
- await pagination.resetToDefaultPageNumber();
- });
-
- it('[C280083] navigate to next and previous pages', async () => {
- await pagination.clickNext();
- await dataTable.waitForHeader();
- expect(await pagination.getRange()).toContain('26-50 of 51');
- expect(await dataTable.isItemPresent('my-file-34')).toBe(true, 'my-file-34 not found on page');
- await pagination.resetToDefaultPageNumber();
-
- await pagination.openCurrentPageMenu();
- await pagination.menu.clickNthItem(2);
- await dataTable.waitForHeader();
- await pagination.clickPrevious();
- await dataTable.waitForHeader();
- expect(await pagination.getRange()).toContain('1-25 of 51');
- expect(await dataTable.isItemPresent('my-file-15')).toBe(true, 'my-file-15 not found on page');
-
- await pagination.resetToDefaultPageNumber();
- });
-
- it('[C280081] Previous button is disabled on first page', async () => {
- expect(await pagination.getCurrentPage()).toContain('Page 1');
- expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled on first page');
- });
-
- it('[C280082] Next button is disabled on last page', async () => {
- await pagination.openCurrentPageMenu();
- await pagination.menu.clickNthItem(3);
- expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
- expect(await pagination.getCurrentPage()).toContain('Page 3');
- expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
- });
- });
-}
diff --git a/projects/aca-playwright-shared/src/api/nodes-api.ts b/projects/aca-playwright-shared/src/api/nodes-api.ts
index b3b341fa1c..7267b471f0 100755
--- a/projects/aca-playwright-shared/src/api/nodes-api.ts
+++ b/projects/aca-playwright-shared/src/api/nodes-api.ts
@@ -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 {
+ 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 {
try {
const userNodes = (await this.getNodeChildren('-my-')).list.entries;
@@ -160,11 +169,12 @@ export class NodesApi {
}
}
- async createContent(content: NodeContentTree, relativePath: string = '/'): Promise {
+ async createContent(content: NodeContentTree, relativePath: string = '/'): Promise {
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 {
- 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 {
diff --git a/projects/aca-playwright-shared/src/page-objects/components/pagination.component.ts b/projects/aca-playwright-shared/src/page-objects/components/pagination.component.ts
index e964929f38..f458881a98 100644
--- a/projects/aca-playwright-shared/src/page-objects/components/pagination.component.ts
+++ b/projects/aca-playwright-shared/src/page-objects/components/pagination.component.ts
@@ -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 {
+ return this.range.innerText();
+ }
+
+ async getMaxItems(): Promise {
+ return this.maxItems.innerText();
+ }
+
+ async getCurrentPage(): Promise {
+ return this.currentPage.innerText();
+ }
+
+ async getTotalPages(): Promise {
+ return this.totalPages.innerText();
+ }
+
+ async isPreviousEnabled(): Promise {
+ return this.previousButton.isEnabled();
+ }
+
+ async isNextEnabled(): Promise {
+ await this.page.waitForTimeout(timeouts.tiny);
+ return this.nextButton.isEnabled();
+ }
+
+ async clickOnNextPage(): Promise {
+ try {
+ if (await this.isNextEnabled()) {
+ await this.nextButton.click();
+ }
+ } catch(error) {
+ throw new Error(`Failed on previous click: ${error}`);
+ }
+ }
+
+ async clickOnPreviousPage(): Promise {
+ try {
+ if (await this.isPreviousEnabled()) {
+ await this.previousButton.click();
+ }
+ } catch(error) {
+ throw new Error(`Failed on previous click: ${error}`);
+ }
+ }
+
+ async openMaxItemsMenu(): Promise {
+ try {
+ await this.maxItemsButton.waitFor({ state: 'visible' });
+ await this.maxItemsButton.click();
+ } catch (error) {
+ throw new Error(`Open max items catch: ${error}`);
+ }
+ }
+
+ async resetToDefaultPageSize(): Promise {
+ 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 {
+ 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 {
+ return this.page.getByRole('menuitem').nth(nth - 1);
+ }
+
+ async getItemsCount(): Promise {
+ return await this.page.getByRole('menuitem').count();
+ }
+
+ async clickNthItem(nth: number): Promise {
+ try {
+ await (await this.getNthItem(nth)).click();
+ } catch (e) {
+ throw new Error(`Click nth menu item catch: ${e}`);
+ }
+ }
}
diff --git a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
index 4baaef79a7..1f2d76ac9c 100644
--- a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
+++ b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
@@ -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 {
await this.acaHeader.createButton.click();
await this.matMenu.createFolder.click();
}
+
+ async closeMenu(): Promise {
+ await this.page.keyboard.press('Escape');
+ }
+
+ async waitForPageLoad() {
+ await this.page.waitForURL(`**/${PersonalFilesPage.pageUrl}`);
+ }
}