From a65a1e6c8e3e1140727220a8189c378e4b8fa5f1 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:15:28 +0530 Subject: [PATCH] chore: reorder class objects Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/ExpandedForm/index.ts | 118 +----------------- .../Dashboard/Grid/Column/LTAR/ChildList.ts | 71 +++++++++++ .../Dashboard/Grid/Column/LTAR/LinkRecord.ts | 51 ++++++++ scripts/playwright/pages/Dashboard/index.ts | 4 +- 4 files changed, 126 insertions(+), 118 deletions(-) create mode 100644 scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts create mode 100644 scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts diff --git a/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts b/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts index a68620619a..c3e9c239cd 100644 --- a/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/scripts/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -1,5 +1,5 @@ // playwright-dev-page.ts -import { expect, Locator } from "@playwright/test"; +import { Locator } from "@playwright/test"; import BasePage from "../../Base"; import { DashboardPage } from ".."; @@ -40,119 +40,3 @@ export class ExpandedFormPage extends BasePage { .waitFor({ state: "hidden" }); } } - -export class ChildList extends BasePage { - readonly dashboard: DashboardPage; - - constructor(dashboard: DashboardPage) { - super(dashboard.rootPage); - this.dashboard = dashboard; - } - - async verify({ - cardTitle, - linkField, - }: { - cardTitle: string[]; - linkField: string; - }) { - // DOM element validation - // title: Child list - // button: Link to 'City' - // icon: reload - expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( - `Child list` - ); - expect( - await this.get() - .locator(`button:has-text("Link to '${linkField}'")`) - .isVisible() - ).toBeTruthy(); - expect( - await this.get().locator(`[data-cy="nc-child-list-reload"]`).isVisible() - ).toBeTruthy(); - - // child list body validation (card count, card title) - const cardCount = cardTitle.length; - await this.get().locator(".ant-modal-content").waitFor(); - { - let childList = this.get().locator(`.ant-card`); - const childCards = await childList.count(); - await expect(childCards).toEqual(cardCount); - for (let i = 0; i < cardCount; i++) { - expect(await childList.nth(i).textContent()).toContain(cardTitle[i]); - // icon: unlink - // icon: delete - expect( - await childList - .nth(i) - .locator(`[data-cy="nc-child-list-icon-unlink"]`) - .isVisible() - ).toBeTruthy(); - expect( - await childList - .nth(i) - .locator(`[data-cy="nc-child-list-icon-delete"]`) - .isVisible() - ).toBeTruthy(); - } - } - } - - async close() { - await this.get().locator(`.ant-modal-close-x`).click(); - await this.get().waitFor({ state: "hidden" }); - } - - get() { - return this.dashboard.get().locator(`.nc-modal-child-list`); - } -} - -export class LinkRecord extends BasePage { - readonly dashboard: DashboardPage; - - constructor(dashboard: DashboardPage) { - super(dashboard.rootPage); - this.dashboard = dashboard; - } - - async verify(cardTitle?: string[]) { - await this.dashboard.get().locator(".nc-modal-link-record").waitFor(); - let linkRecord = await this.get(); - - // DOM element validation - // title: Link Record - // button: Add new record - // icon: reload - expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( - `Link record` - ); - expect( - await linkRecord.locator(`button:has-text("Add new record")`).isVisible() - ).toBeTruthy(); - expect(await linkRecord.locator(`.nc-reload`).isVisible()).toBeTruthy(); - // placeholder: Filter query - expect( - await linkRecord.locator(`[placeholder="Filter query"]`).isVisible() - ).toBeTruthy(); - - { - let childList = linkRecord.locator(`.ant-card`); - const childCards = await childList.count(); - await expect(childCards).toEqual(cardTitle.length); - for (let i = 0; i < cardTitle.length; i++) { - expect(await childList.nth(i).textContent()).toContain(cardTitle[i]); - } - } - } - - async close() { - await this.get().locator(`.ant-modal-close-x`).click(); - await this.get().waitFor({ state: "hidden" }); - } - - get() { - return this.dashboard.get().locator(`.nc-modal-link-record`); - } -} diff --git a/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts new file mode 100644 index 0000000000..b1badd1f82 --- /dev/null +++ b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts @@ -0,0 +1,71 @@ +import BasePage from "../../../../Base"; +import { DashboardPage } from "../../../index"; +import { expect } from "@playwright/test"; + +export class ChildList extends BasePage { + readonly dashboard: DashboardPage; + + constructor(dashboard: DashboardPage) { + super(dashboard.rootPage); + this.dashboard = dashboard; + } + + async verify({ + cardTitle, + linkField, + }: { + cardTitle: string[]; + linkField: string; + }) { + // DOM element validation + // title: Child list + // button: Link to 'City' + // icon: reload + expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( + `Child list` + ); + expect( + await this.get() + .locator(`button:has-text("Link to '${linkField}'")`) + .isVisible() + ).toBeTruthy(); + expect( + await this.get().locator(`[data-cy="nc-child-list-reload"]`).isVisible() + ).toBeTruthy(); + + // child list body validation (card count, card title) + const cardCount = cardTitle.length; + await this.get().locator(".ant-modal-content").waitFor(); + { + let childList = this.get().locator(`.ant-card`); + const childCards = await childList.count(); + await expect(childCards).toEqual(cardCount); + for (let i = 0; i < cardCount; i++) { + expect(await childList.nth(i).textContent()).toContain(cardTitle[i]); + // icon: unlink + // icon: delete + expect( + await childList + .nth(i) + .locator(`[data-cy="nc-child-list-icon-unlink"]`) + .isVisible() + ).toBeTruthy(); + expect( + await childList + .nth(i) + .locator(`[data-cy="nc-child-list-icon-delete"]`) + .isVisible() + ).toBeTruthy(); + } + } + } + + async close() { + await this.get().locator(`.ant-modal-close-x`).click(); + await this.get().waitFor({ state: "hidden" }); + } + + get() { + return this.dashboard.get().locator(`.nc-modal-child-list`); + } +} diff --git a/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts new file mode 100644 index 0000000000..54fee820c9 --- /dev/null +++ b/scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts @@ -0,0 +1,51 @@ +import BasePage from "../../../../Base"; +import { DashboardPage } from "../../../index"; +import { expect } from "@playwright/test"; + +export class LinkRecord extends BasePage { + readonly dashboard: DashboardPage; + + constructor(dashboard: DashboardPage) { + super(dashboard.rootPage); + this.dashboard = dashboard; + } + + async verify(cardTitle?: string[]) { + await this.dashboard.get().locator(".nc-modal-link-record").waitFor(); + let linkRecord = await this.get(); + + // DOM element validation + // title: Link Record + // button: Add new record + // icon: reload + expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( + `Link record` + ); + expect( + await linkRecord.locator(`button:has-text("Add new record")`).isVisible() + ).toBeTruthy(); + expect(await linkRecord.locator(`.nc-reload`).isVisible()).toBeTruthy(); + // placeholder: Filter query + expect( + await linkRecord.locator(`[placeholder="Filter query"]`).isVisible() + ).toBeTruthy(); + + { + let childList = linkRecord.locator(`.ant-card`); + const childCards = await childList.count(); + await expect(childCards).toEqual(cardTitle.length); + for (let i = 0; i < cardTitle.length; i++) { + expect(await childList.nth(i).textContent()).toContain(cardTitle[i]); + } + } + } + + async close() { + await this.get().locator(`.ant-modal-close-x`).click(); + await this.get().waitFor({ state: "hidden" }); + } + + get() { + return this.dashboard.get().locator(`.nc-modal-link-record`); + } +} diff --git a/scripts/playwright/pages/Dashboard/index.ts b/scripts/playwright/pages/Dashboard/index.ts index 3f5bb2951b..f86e1e7b2d 100644 --- a/scripts/playwright/pages/Dashboard/index.ts +++ b/scripts/playwright/pages/Dashboard/index.ts @@ -2,7 +2,9 @@ import { Locator, Page, expect } from "@playwright/test"; import BasePage from "../Base"; import { GridPage } from "./Grid"; -import { ExpandedFormPage, ChildList, LinkRecord } from "./ExpandedForm"; +import { ExpandedFormPage } from "./ExpandedForm"; +import { ChildList } from "./Grid/Column/LTAR/ChildList"; +import { LinkRecord } from "./Grid/Column/LTAR/LinkRecord"; import { TreeViewPage } from "./TreeView"; import { SettingsPage } from "./Settings"; import { ViewSidebarPage } from "./ViewSidebar";