From ec0de9bb32890135fa8ff7d74ec26ad8f0fa7943 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 13 Oct 2022 13:47:34 +0530 Subject: [PATCH] test: pagination class verification fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../playwright/pages/Dashboard/Grid/index.ts | 94 +++++++++++-------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/scripts/playwright/pages/Dashboard/Grid/index.ts b/scripts/playwright/pages/Dashboard/Grid/index.ts index 02f3d1738b..9b00506240 100644 --- a/scripts/playwright/pages/Dashboard/Grid/index.ts +++ b/scripts/playwright/pages/Dashboard/Grid/index.ts @@ -1,10 +1,10 @@ // playwright-dev-page.ts -import { Locator, expect } from '@playwright/test'; -import { DashboardPage } from '..'; -import BasePage from '../../Base'; -import { CellPageObject } from './Cell'; -import { ColumnPageObject } from './Column'; -import { ToolbarPage } from './Toolbar'; +import { Locator, expect } from "@playwright/test"; +import { DashboardPage } from ".."; +import BasePage from "../../Base"; +import { CellPageObject } from "./Cell"; +import { ColumnPageObject } from "./Column"; +import { ToolbarPage } from "./Toolbar"; export class GridPage extends BasePage { readonly dashboard: DashboardPage; @@ -17,7 +17,7 @@ export class GridPage extends BasePage { constructor(dashboardPage: DashboardPage) { super(dashboardPage.rootPage); this.dashboard = dashboardPage; - this.addNewTableButton = dashboardPage.get().locator('.nc-add-new-table'); + this.addNewTableButton = dashboardPage.get().locator(".nc-add-new-table"); this.column = new ColumnPageObject(this); this.cell = new CellPageObject(this); this.toolbar = new ToolbarPage(this); @@ -32,69 +32,87 @@ export class GridPage extends BasePage { } async rowCount() { - await this.get().locator('.nc-grid-row').count(); + await this.get().locator(".nc-grid-row").count(); } - async verifyRowCount({count}: {count: number}) { - return expect(await this.get().locator('.nc-grid-row').count()).toBe(count); + async verifyRowCount({ count }: { count: number }) { + return expect(await this.get().locator(".nc-grid-row").count()).toBe(count); } - async addNewRow({index = 0, title}: {index?: number, title?: string} = {}) { - const rowCount = await this.get().locator('.nc-grid-row').count(); - await this.get().locator('.nc-grid-add-new-cell').click(); - if(rowCount + 1 !== await this.get().locator('.nc-grid-row').count()) { - await this.get().locator('.nc-grid-add-new-cell').click(); + async addNewRow({ + index = 0, + title, + }: { index?: number; title?: string } = {}) { + const rowCount = await this.get().locator(".nc-grid-row").count(); + await this.get().locator(".nc-grid-add-new-cell").click(); + if (rowCount + 1 !== (await this.get().locator(".nc-grid-row").count())) { + await this.get().locator(".nc-grid-add-new-cell").click(); } - const cell = this.cell.get({index, columnHeader: 'Title'}); + const cell = this.cell.get({ index, columnHeader: "Title" }); await this.cell.dblclick({ index, - columnHeader: 'Title' + columnHeader: "Title", }); - - await cell.locator('input').fill(title ?? `Row ${index}`); - await cell.locator('input').press('Enter'); + await cell.locator("input").fill(title ?? `Row ${index}`); + await cell.locator("input").press("Enter"); } - async verifyRow({index}: {index: number}) { - await this.get().locator(`td[data-pw="cell-Title-${index}"]`).waitFor({state: 'visible'}); - expect(await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()).toBe(1); + async verifyRow({ index }: { index: number }) { + await this.get() + .locator(`td[data-pw="cell-Title-${index}"]`) + .waitFor({ state: "visible" }); + expect( + await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count() + ).toBe(1); } - async verifyRowDoesNotExist({index}: {index: number}) { - await this.get().locator(`td[data-pw="cell-Title-${index}"]`).waitFor({state: 'hidden'}); - return expect(await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()).toBe(0); + async verifyRowDoesNotExist({ index }: { index: number }) { + await this.get() + .locator(`td[data-pw="cell-Title-${index}"]`) + .waitFor({ state: "hidden" }); + return expect( + await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count() + ).toBe(0); } async deleteRow(index: number) { await this.get().locator(`td[data-pw="cell-Title-${index}"]`).click({ - button: 'right' + button: "right", }); // Click text=Delete Row - await this.rootPage.locator('text=Delete Row').click(); + await this.rootPage.locator("text=Delete Row").click(); // todo: improve selector - await this.rootPage.locator('span.ant-dropdown-menu-title-content > nc-project-menu-item').waitFor({state: 'hidden'}); + await this.rootPage + .locator("span.ant-dropdown-menu-title-content > nc-project-menu-item") + .waitFor({ state: "hidden" }); await this.rootPage.waitForTimeout(300); } - async openExpandedRow({index}:{index: number}) { + async openExpandedRow({ index }: { index: number }) { await this.row(index).locator(`td[pw-data="cell-id-${index}"]`).hover(); await this.row(index).locator(`div[pw-data="nc-expand-${index}"]`).click(); } async selectAll() { await this.get().locator('[pw-data="nc-check-all"]').hover(); - await this.get().locator('[pw-data="nc-check-all"]').locator('input[type="checkbox"]').click(); + await this.get() + .locator('[pw-data="nc-check-all"]') + .locator('input[type="checkbox"]') + .click(); } async deleteAll() { await this.selectAll(); - await this.get().locator('[pw-data="nc-check-all"]').locator('input[type="checkbox"]').click({ - button: 'right' - }); - await this.rootPage.locator('text=Delete Selected Rows').click(); + await this.get() + .locator('[pw-data="nc-check-all"]') + .locator('input[type="checkbox"]') + .click({ + button: "right", + }); + await this.rootPage.locator("text=Delete Selected Rows").click(); } async pagination({ page }: { page: string }) { @@ -111,6 +129,8 @@ export class GridPage extends BasePage { } async verifyActivePage({ page }: { page: string }) { - expect(await this.pagination({ page })).toHaveClass("ant-pagination-item-active"); + expect(await this.pagination({ page })).toHaveClass( + /ant-pagination-item-active/ + ); } -} \ No newline at end of file +}