From 1ff8329b4ba549729623249de6e870cc42cf5908 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 14 Oct 2022 17:39:25 +0530 Subject: [PATCH] test: ltar column Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/ExpandedForm/index.ts | 18 ++- .../pages/Dashboard/Grid/Cell/index.ts | 13 ++ .../Dashboard/Grid/Column/LTAR/LinkRecord.ts | 6 + .../pages/Dashboard/Grid/Column/index.ts | 18 +++ .../playwright/pages/Dashboard/TreeView.ts | 39 ++++-- .../tests/linkToAnotherRecord.spec.ts | 118 ++++++++++++++++++ 6 files changed, 199 insertions(+), 13 deletions(-) create mode 100644 scripts/playwright/tests/linkToAnotherRecord.spec.ts diff --git a/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts b/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts index 3d08893018..6c571f411e 100644 --- a/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -20,14 +20,30 @@ export class ExpandedFormPage extends BasePage { async fillField({ columnTitle, value, + type = "text", }: { columnTitle: string; value: string; + type?: string; }) { const field = this.get().locator( `[pw-data="nc-expand-col-${columnTitle}"]` ); - await field.locator("input").fill(value); + await field.hover(); + switch (type) { + case "text": + await field.locator("input").fill(value); + break; + case "belongsTo": + await field.locator(".nc-action-icon").click(); + await this.dashboard.linkRecord.select(value); + break; + case "hasMany": + case "manyToMany": + await field.locator(`[data-cy="nc-child-list-button-link-to"]`).click(); + await this.dashboard.linkRecord.select(value); + break; + } } async save() { diff --git a/scripts/playwright/pages/Dashboard/Grid/Cell/index.ts b/scripts/playwright/pages/Dashboard/Grid/Cell/index.ts index 93c6947563..6bda707d8e 100644 --- a/scripts/playwright/pages/Dashboard/Grid/Cell/index.ts +++ b/scripts/playwright/pages/Dashboard/Grid/Cell/index.ts @@ -58,6 +58,19 @@ export class CellPageObject extends BasePage { .click(); } + async inCellAdd({ + index, + columnHeader, + }: { + index: number; + columnHeader: string; + }) { + await this.get({ index, columnHeader }).hover(); + await this.get({ index, columnHeader }) + .locator(".nc-action-icon.nc-plus") + .click(); + } + async verify({ index, columnHeader, diff --git a/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts index 54fee820c9..bd6e3adbb7 100644 --- a/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts +++ b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts @@ -40,6 +40,12 @@ export class LinkRecord extends BasePage { } } + async select(cardTitle: string) { + await this.get() + .locator(`.ant-card:has-text("${cardTitle}"):visible`) + .click(); + } + async close() { await this.get().locator(`.ant-modal-close-x`).click(); await this.get().waitFor({ state: "hidden" }); diff --git a/scripts/playwright/pages/Dashboard/Grid/Column/index.ts b/scripts/playwright/pages/Dashboard/Grid/Column/index.ts index 424ef8fa36..727ad4a0e6 100644 --- a/scripts/playwright/pages/Dashboard/Grid/Column/index.ts +++ b/scripts/playwright/pages/Dashboard/Grid/Column/index.ts @@ -23,6 +23,7 @@ export class ColumnPageObject extends BasePage { formula = "", childTable = "", childColumn = "", + relationType = "", rollupType = "", format = "", }: { @@ -31,6 +32,7 @@ export class ColumnPageObject extends BasePage { formula?: string; childTable?: string; childColumn?: string; + relationType?: string; rollupType?: string; format?: string; }) { @@ -103,6 +105,22 @@ export class ColumnPageObject extends BasePage { .nth(0) .click(); break; + case "LinkToAnotherRecord": + await this.get() + .locator(".nc-ltar-relation-type >> .ant-radio") + .nth(relationType === "Has Many" ? 0 : 1) + .click(); + await this.get().locator(".ant-select-single").nth(1).click(); + await this.rootPage + .locator(`.nc-ltar-child-table >> input[type="search"]`) + .fill(childTable); + await this.rootPage + .locator(`.nc-dropdown-ltar-child-table >> .ant-select-item`, { + hasText: childTable, + }) + .nth(0) + .click(); + break; default: break; } diff --git a/scripts/playwright/pages/Dashboard/TreeView.ts b/scripts/playwright/pages/Dashboard/TreeView.ts index d09954686c..983228e062 100644 --- a/scripts/playwright/pages/Dashboard/TreeView.ts +++ b/scripts/playwright/pages/Dashboard/TreeView.ts @@ -32,7 +32,10 @@ export class TreeViewPage extends BasePage { await this.dashboard.get().locator(".ant-modal-body").waitFor(); - await this.dashboard.get().locator('[placeholder="Enter table name"]').fill(title); + await this.dashboard + .get() + .locator('[placeholder="Enter table name"]') + .fill(title); await this.dashboard.get().locator('button:has-text("Submit")').click(); await this.dashboard.waitForTabRender({ title }); @@ -43,8 +46,10 @@ export class TreeViewPage extends BasePage { this.get().locator(`.nc-project-tree-tbl-${title}`) ).toBeVisible(); - if(index) { - expect(await this.get().locator('.nc-tbl-title').nth(index)).toHaveText(title); + if (index) { + expect(await this.get().locator(".nc-tbl-title").nth(index)).toHaveText( + title + ); } } @@ -58,7 +63,8 @@ export class TreeViewPage extends BasePage { await this.get() .locator(`.nc-project-tree-tbl-${title}`) .click({ button: "right" }); - await this.dashboard.get() + await this.dashboard + .get() .locator('div.nc-project-menu-item:has-text("Delete")') .click(); await this.dashboard.get().locator('button:has-text("Yes")').click(); @@ -69,21 +75,30 @@ export class TreeViewPage extends BasePage { await this.get() .locator(`.nc-project-tree-tbl-${title}`) .click({ button: "right" }); - await this.dashboard.get() + await this.dashboard + .get() .locator('div.nc-project-menu-item:has-text("Rename")') .click(); - await this.dashboard.get().locator('[placeholder="Enter table name"]').fill(newTitle); + await this.dashboard + .get() + .locator('[placeholder="Enter table name"]') + .fill(newTitle); await this.dashboard.get().locator('button:has-text("Submit")').click(); - await this.toastWait({ message: "Table renamed successfully" }); + await this.toastWait({ message: "Table renamed successfully" }); } - async reorderTables({ sourceTable, destinationTable}: { + async reorderTables({ + sourceTable, + destinationTable, + }: { sourceTable: string; destinationTable: string; }) { - - await this.dashboard.get().locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`).dragTo( - this.get().locator(`[pw-data="tree-view-table-${destinationTable}"]`), - ); + await this.dashboard + .get() + .locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`) + .dragTo( + this.get().locator(`[pw-data="tree-view-table-${destinationTable}"]`) + ); } } diff --git a/scripts/playwright/tests/linkToAnotherRecord.spec.ts b/scripts/playwright/tests/linkToAnotherRecord.spec.ts new file mode 100644 index 0000000000..7d99120742 --- /dev/null +++ b/scripts/playwright/tests/linkToAnotherRecord.spec.ts @@ -0,0 +1,118 @@ +import { test } from "@playwright/test"; +import { DashboardPage } from "../pages/Dashboard"; +import setup from "../setup"; + +test.describe("LTAR create & update", () => { + let dashboard: DashboardPage; + let context: any; + + test.beforeEach(async ({ page }) => { + context = await setup({ page }); + dashboard = new DashboardPage(page, context.project); + }); + + test("LTAR", async () => { + // close 'Team & Auth' tab + await dashboard.closeTab({ title: "Team & Auth" }); + + await dashboard.treeView.createTable({ title: "Sheet1" }); + // subsequent table creation fails; hence delay + await dashboard.rootPage.waitForTimeout(1000); + await dashboard.treeView.createTable({ title: "Sheet2" }); + + await dashboard.treeView.openTable({ title: "Sheet1" }); + await dashboard.grid.addNewRow({ index: 0, value: "1a" }); + await dashboard.grid.addNewRow({ index: 1, value: "1b" }); + await dashboard.grid.addNewRow({ index: 2, value: "1c" }); + + // Create LTAR-HM column + await dashboard.grid.column.create({ + title: "Link1-2hm", + type: "LinkToAnotherRecord", + childTable: "Sheet2", + relationType: "Has Many", + }); + await dashboard.grid.column.create({ + title: "Link1-2mm", + type: "LinkToAnotherRecord", + childTable: "Sheet2", + relationType: "Many To many", + }); + await dashboard.closeTab({ title: "Sheet1" }); + + await dashboard.treeView.openTable({ title: "Sheet2" }); + await dashboard.grid.column.create({ + title: "Link2-1hm", + type: "LinkToAnotherRecord", + childTable: "Sheet1", + relationType: "Has Many", + }); + + // Sheet2 now has all 3 column categories : HM, BT, MM + // + + // Expanded form insert + + await dashboard.grid.toolbar.clickAddNewRow(); + await dashboard.expandedForm.fillField({ + columnTitle: "Title", + value: "2a", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Sheet1", + value: "1a", + type: "belongsTo", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Sheet1 List", + value: "1a", + type: "manyToMany", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Link2-1hm", + value: "1a", + type: "hasMany", + }); + await dashboard.expandedForm.save(); + + // In cell insert + await dashboard.grid.addNewRow({ index: 1, value: "2b" }); + await dashboard.grid.cell.inCellAdd({ index: 1, columnHeader: "Sheet1" }); + await dashboard.linkRecord.select("1b"); + await dashboard.grid.cell.inCellAdd({ + index: 1, + columnHeader: "Sheet1 List", + }); + await dashboard.linkRecord.select("1b"); + await dashboard.grid.cell.inCellAdd({ + index: 1, + columnHeader: "Link2-1hm", + }); + await dashboard.linkRecord.select("1b"); + + // Expand record insert + await dashboard.grid.addNewRow({ index: 2, value: "2c-temp" }); + await dashboard.grid.openExpandedRow({ index: 2 }); + await dashboard.expandedForm.fillField({ + columnTitle: "Sheet1", + value: "1c", + type: "belongsTo", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Sheet1 List", + value: "1c", + type: "manyToMany", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Link2-1hm", + value: "1c", + type: "hasMany", + }); + await dashboard.expandedForm.fillField({ + columnTitle: "Title", + value: "2c", + type: "text", + }); + await dashboard.expandedForm.save(); + }); +});