Browse Source

test: ltar column

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
1ff8329b4b
  1. 18
      scripts/playwright/pages/Dashboard/ExpandedForm/index.ts
  2. 13
      scripts/playwright/pages/Dashboard/Grid/Cell/index.ts
  3. 6
      scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts
  4. 18
      scripts/playwright/pages/Dashboard/Grid/Column/index.ts
  5. 39
      scripts/playwright/pages/Dashboard/TreeView.ts
  6. 118
      scripts/playwright/tests/linkToAnotherRecord.spec.ts

18
scripts/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -20,14 +20,30 @@ export class ExpandedFormPage extends BasePage {
async fillField({ async fillField({
columnTitle, columnTitle,
value, value,
type = "text",
}: { }: {
columnTitle: string; columnTitle: string;
value: string; value: string;
type?: string;
}) { }) {
const field = this.get().locator( const field = this.get().locator(
`[pw-data="nc-expand-col-${columnTitle}"]` `[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() { async save() {

13
scripts/playwright/pages/Dashboard/Grid/Cell/index.ts

@ -58,6 +58,19 @@ export class CellPageObject extends BasePage {
.click(); .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({ async verify({
index, index,
columnHeader, columnHeader,

6
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() { async close() {
await this.get().locator(`.ant-modal-close-x`).click(); await this.get().locator(`.ant-modal-close-x`).click();
await this.get().waitFor({ state: "hidden" }); await this.get().waitFor({ state: "hidden" });

18
scripts/playwright/pages/Dashboard/Grid/Column/index.ts

@ -23,6 +23,7 @@ export class ColumnPageObject extends BasePage {
formula = "", formula = "",
childTable = "", childTable = "",
childColumn = "", childColumn = "",
relationType = "",
rollupType = "", rollupType = "",
format = "", format = "",
}: { }: {
@ -31,6 +32,7 @@ export class ColumnPageObject extends BasePage {
formula?: string; formula?: string;
childTable?: string; childTable?: string;
childColumn?: string; childColumn?: string;
relationType?: string;
rollupType?: string; rollupType?: string;
format?: string; format?: string;
}) { }) {
@ -103,6 +105,22 @@ export class ColumnPageObject extends BasePage {
.nth(0) .nth(0)
.click(); .click();
break; 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: default:
break; break;
} }

39
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(".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.get().locator('button:has-text("Submit")').click();
await this.dashboard.waitForTabRender({ title }); await this.dashboard.waitForTabRender({ title });
@ -43,8 +46,10 @@ export class TreeViewPage extends BasePage {
this.get().locator(`.nc-project-tree-tbl-${title}`) this.get().locator(`.nc-project-tree-tbl-${title}`)
).toBeVisible(); ).toBeVisible();
if(index) { if (index) {
expect(await this.get().locator('.nc-tbl-title').nth(index)).toHaveText(title); expect(await this.get().locator(".nc-tbl-title").nth(index)).toHaveText(
title
);
} }
} }
@ -58,7 +63,8 @@ export class TreeViewPage extends BasePage {
await this.get() await this.get()
.locator(`.nc-project-tree-tbl-${title}`) .locator(`.nc-project-tree-tbl-${title}`)
.click({ button: "right" }); .click({ button: "right" });
await this.dashboard.get() await this.dashboard
.get()
.locator('div.nc-project-menu-item:has-text("Delete")') .locator('div.nc-project-menu-item:has-text("Delete")')
.click(); .click();
await this.dashboard.get().locator('button:has-text("Yes")').click(); await this.dashboard.get().locator('button:has-text("Yes")').click();
@ -69,21 +75,30 @@ export class TreeViewPage extends BasePage {
await this.get() await this.get()
.locator(`.nc-project-tree-tbl-${title}`) .locator(`.nc-project-tree-tbl-${title}`)
.click({ button: "right" }); .click({ button: "right" });
await this.dashboard.get() await this.dashboard
.get()
.locator('div.nc-project-menu-item:has-text("Rename")') .locator('div.nc-project-menu-item:has-text("Rename")')
.click(); .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.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; sourceTable: string;
destinationTable: string; destinationTable: string;
}) { }) {
await this.dashboard
await this.dashboard.get().locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`).dragTo( .get()
this.get().locator(`[pw-data="tree-view-table-${destinationTable}"]`), .locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`)
); .dragTo(
this.get().locator(`[pw-data="tree-view-table-${destinationTable}"]`)
);
} }
} }

118
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();
});
});
Loading…
Cancel
Save