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..31f88fe03a --- /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 files = Array(51) + .fill('my-file') + .map((name, index): string => `${name}-${index + 1}-${random}.txt`); + + const apiClientFactory = new ApiClientFactory(); + + test.beforeAll(async () => { + await apiClientFactory.setUpAcaBackend('admin'); + await apiClientFactory.createUser({ username }); + const nodesApi = await NodesApi.initialize(username, username); + parentId = (await nodesApi.createFolder(parent)).entry.id; + + (await nodesApi.createFiles(files, parent)).list.entries.map((entries: any) => 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..24570b4bcc --- /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.only('Pagination controls : ', () => { + test.beforeEach(async ({ loginPage, personalFiles, page }) => { + await loginPage.navigate(); + await loginPage.loginUser({ username: userName, password: userName }); + await personalFiles.navigate(); + 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.menu.getNthItem(1)).innerText()).toBe('25'); + expect(await (await personalFiles.pagination.menu.getNthItem(2)).innerText()).toBe('50'); + expect(await (await personalFiles.pagination.menu.getNthItem(3)).innerText()).toBe('100'); + await personalFiles.closeMenu(); + }); + + test('[C280079] current page menu items', async ({ personalFiles }) => { + await personalFiles.pagination.openMaxItemsMenu(); + await personalFiles.pagination.menu.clickMenuItem('25'); + expect(await personalFiles.pagination.getMaxItems()).toContain('25'); + expect(await personalFiles.pagination.getTotalPages()).toContain('of 3'); + expect(await personalFiles.pagination.menu.getItemsCount()).toBe(3); + + await personalFiles.pagination.openMaxItemsMenu(); + await personalFiles.pagination.menu.clickMenuItem('50'); + expect(await personalFiles.pagination.getMaxItems()).toContain('50'); + expect(await personalFiles.pagination.getTotalPages()).toContain('of 2'); + + await personalFiles.pagination.openMaxItemsMenu(); + await personalFiles.pagination.menu.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.menu.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.menu.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..059f5741d7 --- /dev/null +++ b/e2e/playwright/pagination/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es2017", + "types": ["jasmine", "jasminewd2", "node", "@playwright/test"], + "skipLibCheck": true + }, + "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..7440722fcc 100755 --- a/projects/aca-playwright-shared/src/api/nodes-api.ts +++ b/projects/aca-playwright-shared/src/api/nodes-api.ts @@ -73,6 +73,14 @@ export class NodesApi { } } + async createFiles(names: string[], relativePath: string = '/'): Promise { + try { + return await this.createContent({ files: names }, relativePath); + } catch (error) { + throw new Error(`${this.constructor.name} ${this.createFiles.name}: ${error}`); + } + } + private async createNode( nodeType: string, name: string, diff --git a/projects/aca-playwright-shared/src/page-objects/components/menu.component.ts b/projects/aca-playwright-shared/src/page-objects/components/menu.component.ts new file mode 100644 index 0000000000..c43e7c389c --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/menu.component.ts @@ -0,0 +1,64 @@ +/*! + * 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 { BaseComponent } from './base.component'; +import { Locator, Page } from '@playwright/test'; + +export class MenuComponent extends BaseComponent { + private static rootElement = '.mat-menu-panel'; + + constructor(page: Page) { + super(page, MenuComponent.rootElement); + } + + items = this.getChild('.mat-menu-item'); + + async getNthItem(nth: number): Promise { + return this.items.nth(nth - 1); + } + + async getItemByLabel(menuItem: string): Promise { + return this.items.getByText(menuItem); + } + + async clickMenuItem(menuItem: string): Promise { + try { + await this.page.locator('.mat-menu-item').getByText(menuItem).click(); + } catch (e) { + throw new Error(`Click menu item catch : failed to click on ${menuItem}`); + } + } + + async getItemsCount(): Promise { + return this.items.count(); + } + + async clickNthItem(nth: number): Promise { + try { + (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/components/pagination.component.ts b/projects/aca-playwright-shared/src/page-objects/components/pagination.component.ts index e964929f38..397e9c9429 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 @@ -25,6 +25,8 @@ import { BaseComponent } from './base.component'; import { Page } from '@playwright/test'; import { MatMenuComponent } from './dataTable/mat-menu.component'; +import { MenuComponent } from './menu.component'; +import { timeouts } from '../../utils'; export enum PaginationActionsType { PageSizeSelector = 'Page size selector', @@ -39,7 +41,16 @@ export class PaginationComponent extends BaseComponent { super(page, PaginationComponent.rootElement); } + range = this.getChild('.adf-pagination__range'); + maxItems = this.getChild('.adf-pagination__max-items'); + currentPage = this.getChild('.adf-pagination__current-page'); + totalPages = this.getChild('.adf-pagination__total-pages'); + previousButton = this.getChild('.adf-pagination__previous-button'); + nextButton = this.getChild('.adf-pagination__next-button'); + maxItemsButton = this.getChild('.adf-pagination__max-items + button[mat-icon-button]'); + private itemsPerPageMenu = new MatMenuComponent(this.page); + public menu = new MenuComponent(this.page); public currentPageLocator = this.getChild('.adf-pagination__current-page'); public totalPageLocator = this.getChild('.adf-pagination__total-pages'); @@ -65,4 +76,56 @@ 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 { + return await this.nextButton.click(); + } + + async clickOnPreviousPage(): Promise { + return await this.previousButton.click(); + } + + 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.menu.clickNthItem(1); + await this.page.waitForTimeout(timeouts.tiny); + } catch (error) { + throw new Error(`Reset to default page size catch: ${error}`); + } + } } 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..c4997865bc 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,14 @@ 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 { + this.page.keyboard.press('Escape'); + } }