Skip to content

Commit

Permalink
[ACS-6239] Removed material classes and used roles for test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kritagya09 committed Nov 22, 2023
1 parent b3ccfb3 commit b98b236
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
18 changes: 9 additions & 9 deletions e2e/playwright/pagination/src/tests/personal-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');
Expand All @@ -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);
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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');
Expand Down Expand Up @@ -122,10 +120,34 @@ export class PaginationComponent extends BaseComponent {
async resetToDefaultPageSize(): Promise<void> {
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<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}`);
}
}
}

0 comments on commit b98b236

Please sign in to comment.