From b98b236020867ad9909a74955ccd15d9892287e7 Mon Sep 17 00:00:00 2001 From: kritagya09 Date: Wed, 22 Nov 2023 16:10:59 +0530 Subject: [PATCH] [ACS-6239] Removed material classes and used roles for test cases --- .../src/tests/multiple-pages-files.spec.ts | 2 +- .../pagination/src/tests/personal-files.ts | 18 +++--- .../page-objects/components/menu.component.ts | 60 ------------------- .../components/pagination.component.ts | 30 ++++++++-- 4 files changed, 36 insertions(+), 74 deletions(-) delete mode 100644 projects/aca-playwright-shared/src/page-objects/components/menu.component.ts diff --git a/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts b/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts index b43e669f88..816ab3ff83 100755 --- a/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts +++ b/e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts @@ -44,7 +44,7 @@ test.describe('Pagination on multiple pages : ', () => { .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: any) => entries.entry.id); + (await nodesApi.createFiles(files, parent)).list.entries.map((entries) => entries.entry.id); }); test.afterAll(async () => { diff --git a/e2e/playwright/pagination/src/tests/personal-files.ts b/e2e/playwright/pagination/src/tests/personal-files.ts index 04d30c55ca..8f4e423c58 100644 --- a/e2e/playwright/pagination/src/tests/personal-files.ts +++ b/e2e/playwright/pagination/src/tests/personal-files.ts @@ -46,26 +46,26 @@ export function personalFilesTests(userName: string, parentName: string) { 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'); + 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.menu.clickMenuItem('25'); + await personalFiles.pagination.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); + expect(await personalFiles.pagination.getItemsCount()).toBe(3); await personalFiles.pagination.openMaxItemsMenu(); - await personalFiles.pagination.menu.clickMenuItem('50'); + 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.menu.clickMenuItem('100'); + await personalFiles.pagination.clickMenuItem('100'); expect(await personalFiles.pagination.getMaxItems()).toContain('100'); expect(await personalFiles.pagination.getTotalPages()).toContain('of 1'); @@ -83,7 +83,7 @@ export function personalFilesTests(userName: string, parentName: string) { test('[C280083] navigate to next and previous pages', async ({ personalFiles }) => { await personalFiles.pagination.openMaxItemsMenu(); - await personalFiles.pagination.menu.clickMenuItem('25'); + 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'); @@ -99,7 +99,7 @@ export function personalFilesTests(userName: string, parentName: string) { test('[C280082] Next button is disabled on last page', async ({ personalFiles }) => { await personalFiles.pagination.openMaxItemsMenu(); - await personalFiles.pagination.menu.clickNthItem(3); + await personalFiles.pagination.clickNthItem(3); expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1'); expect(await personalFiles.pagination.isNextEnabled()).toBe(false); }); 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 deleted file mode 100644 index 7087adef47..0000000000 --- a/projects/aca-playwright-shared/src/page-objects/components/menu.component.ts +++ /dev/null @@ -1,60 +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 { 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 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 397e9c9429..75caee001d 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,9 +23,8 @@ */ import { BaseComponent } from './base.component'; -import { Page } from '@playwright/test'; +import { Locator, Page } from '@playwright/test'; import { MatMenuComponent } from './dataTable/mat-menu.component'; -import { MenuComponent } from './menu.component'; import { timeouts } from '../../utils'; export enum PaginationActionsType { @@ -50,7 +49,6 @@ export class PaginationComponent extends BaseComponent { 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'); @@ -122,10 +120,34 @@ export class PaginationComponent extends BaseComponent { async resetToDefaultPageSize(): Promise { try { await this.openMaxItemsMenu(); - await this.menu.clickNthItem(1); + 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}`); + } + } }