From 232519bf2fa599616282c5a7096152e0e096d4fa Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 10 Oct 2022 15:02:10 +0530 Subject: [PATCH] feat(testing): Improved column page object --- scripts/playwright/pages/Column/index.ts | 33 +++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/playwright/pages/Column/index.ts b/scripts/playwright/pages/Column/index.ts index 2cd9a6ac0c..48d1a1e005 100644 --- a/scripts/playwright/pages/Column/index.ts +++ b/scripts/playwright/pages/Column/index.ts @@ -13,21 +13,22 @@ export class ColumnPageObject { this.basePage = new BasePage(this.page); } - async create({title, type}: {title: string, type: string}) { + get() { + return this.page.locator('[data-pw="add-or-edit-column"]'); + } + + async create({title, type = "SingleLineText"}: {title: string, type?: string}) { await this.page.locator('.nc-column-add').click(); await this.page.locator('form[data-pw="add-or-edit-column"]').waitFor(); - // Click span:has-text("SingleLineText") >> nth=1 - await this.page.locator('span:has-text("SingleLineText")').click(); - - // Fill text=Column Type SingleLineText >> input[role="combobox"] - await this.page.locator('text=Column Type SingleLineText >> input[role="combobox"]').fill(type); - - // Select column type - await this.page.locator(`text=${type}`).nth(1).click(); + await this.fillTitle({title}); + + await this.selectType({type}); switch (type) { + case "SingleTextLine": + break; case 'SingleSelect': case 'MultiSelect': await this.selectOption.addOption({index: 0, option: 'Option 1', skipColumnModal: true}); @@ -37,9 +38,21 @@ export class ColumnPageObject { break; } + await this.save(); + } + + async fillTitle({title}: {title: string}) { await this.page.locator('.nc-column-name-input').fill(title); + } - await this.save(); + async selectType({type}: {type: string}) { + await this.get().locator('.ant-select-selector > .ant-select-selection-item').click(); + + await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor(); + await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); + + // Select column type + await this.page.locator(`text=${type}`).nth(1).click(); } async delete({title}: {title: string}) {