diff --git a/scripts/playwright/pages/Dashboard/Grid/Column/index.ts b/scripts/playwright/pages/Dashboard/Grid/Column/index.ts index b17c734e58..711189d28a 100644 --- a/scripts/playwright/pages/Dashboard/Grid/Column/index.ts +++ b/scripts/playwright/pages/Dashboard/Grid/Column/index.ts @@ -21,10 +21,16 @@ export class ColumnPageObject extends BasePage { title, type = "SingleLineText", formula = "", + childTable = "", + childColumn = "", + rollupType = "", }: { title: string; type?: string; formula?: string; + childTable?: string; + childColumn?: string; + rollupType?: string; }) { await this.grid.get().locator(".nc-column-add").click(); await this.rootPage.waitForTimeout(500); @@ -52,6 +58,41 @@ export class ColumnPageObject extends BasePage { case "Formula": await this.get().locator(".nc-formula-input").fill(formula); break; + case "Lookup": + await this.get().locator(".ant-select-single").nth(1).click(); + await this.rootPage + .locator(`.ant-select-item`, { + hasText: childTable, + }) + .click(); + await this.get().locator(".ant-select-single").nth(2).click(); + await this.rootPage + .locator(`.ant-select-item`, { + hasText: childColumn, + }) + .click(); + break; + case "Rollup": + await this.get().locator(".ant-select-single").nth(1).click(); + await this.rootPage + .locator(`.ant-select-item`, { + hasText: childTable, + }) + .click(); + await this.get().locator(".ant-select-single").nth(2).click(); + await this.rootPage + .locator(`.nc-dropdown-relation-column >> .ant-select-item`, { + hasText: childColumn, + }) + .click(); + await this.get().locator(".ant-select-single").nth(3).click(); + await this.rootPage + .locator(`.nc-dropdown-rollup-function >> .ant-select-item`, { + hasText: rollupType, + }) + .nth(0) + .click(); + break; default: break; } diff --git a/scripts/playwright/tests/lookupRollup.spec.ts b/scripts/playwright/tests/lookupRollup.spec.ts new file mode 100644 index 0000000000..6ab540c208 --- /dev/null +++ b/scripts/playwright/tests/lookupRollup.spec.ts @@ -0,0 +1,56 @@ +import { test } from "@playwright/test"; +import { DashboardPage } from "../pages/Dashboard"; +import setup from "../setup"; + +test.describe.only("Virtual columns", () => { + let dashboard: DashboardPage; + let context: any; + + test.beforeEach(async ({ page }) => { + context = await setup({ page }); + dashboard = new DashboardPage(page, context.project); + }); + + test("Lookup", async () => { + // close 'Team & Auth' tab + // await dashboard.closeTab({ title: "Team & Auth" }); + + const pinCode = ["4166", "77459", "41136", "8268", "33463"]; + const cityCount = ["1", "3", "1", "2", "1"]; + + await dashboard.treeView.openTable({ title: "City" }); + // Create LookUp column + await dashboard.grid.column.create({ + title: "Lookup", + type: "Lookup", + childTable: "Address List", + childColumn: "PostalCode", + }); + for (let i = 0; i < pinCode.length; i++) { + await dashboard.grid.cell.verify({ + index: i, + columnHeader: "Lookup", + value: pinCode[i], + }); + } + await dashboard.closeTab({ title: "City" }); + + await dashboard.treeView.openTable({ title: "Country" }); + // Create Rollup column + await dashboard.grid.column.create({ + title: "Rollup", + type: "Rollup", + childTable: "City List", + childColumn: "City", + rollupType: "count", + }); + for (let i = 0; i < pinCode.length; i++) { + await dashboard.grid.cell.verify({ + index: i, + columnHeader: "Rollup", + value: cityCount[i], + }); + } + await dashboard.closeTab({ title: "Country" }); + }); +});