Browse Source

test: pagination

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3848/head
Raju Udava 2 years ago committed by Muhammed Mustafa
parent
commit
030453a97d
  1. 21
      scripts/playwright/pages/Dashboard/Grid/index.ts
  2. 26
      scripts/playwright/tests/pagination.spec.ts

21
scripts/playwright/pages/Dashboard/Grid/index.ts

@ -34,14 +34,14 @@ export class GridPage extends BasePage {
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'});
await this.cell.dblclick({
index,
columnHeader: 'Title'
});
await cell.locator('input').fill(title ?? `Row ${index}`);
await cell.locator('input').press('Enter');
}
@ -85,4 +85,21 @@ export class GridPage extends BasePage {
});
await this.rootPage.locator('text=Delete Selected Rows').click();
}
async pagination({ page }: { page: string }) {
await this.get().locator(`.nc-pagination`).waitFor();
if (page === "<")
return this.get().locator(".nc-pagination > .ant-pagination-prev");
if (page === ">")
return this.get().locator(".nc-pagination > .ant-pagination-next");
return this.get().locator(
`.nc-pagination > .ant-pagination-item.ant-pagination-item-${page}`
);
}
async verifyActivePage({ page }: { page: string }) {
expect(await this.pagination({ page })).toHaveClass("ant-pagination-item-active");
}
}

26
scripts/playwright/tests/pagination.spec.ts

@ -0,0 +1,26 @@
import { test } from "@playwright/test";
import { DashboardPage } from "../pages/Dashboard";
import setup from "../setup";
test.describe("Grid pagination", () => {
let dashboard: DashboardPage;
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
});
test("Access next page, prev page & offset page", async () => {
// close 'Team & Auth' tab
await dashboard.closeTab({ title: "Team & Auth" });
await dashboard.treeView.openTable({ title: "Country" });
// click ">" to go to next page
(await dashboard.grid.pagination({ page: ">" })).click();
await dashboard.grid.verifyActivePage({ page: "2" });
// click "<" to go to prev page
(await dashboard.grid.pagination({ page: "<" })).click();
await dashboard.grid.verifyActivePage({ page: "1" });
});
});
Loading…
Cancel
Save