diff --git a/scripts/playwright/pages/Dashboard/Grid/index.ts b/scripts/playwright/pages/Dashboard/Grid/index.ts index 18f1a3ba29..3212c6b97c 100644 --- a/scripts/playwright/pages/Dashboard/Grid/index.ts +++ b/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"); + } } \ No newline at end of file diff --git a/scripts/playwright/tests/pagination.spec.ts b/scripts/playwright/tests/pagination.spec.ts new file mode 100644 index 0000000000..026c736393 --- /dev/null +++ b/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" }); + }); +});