diff --git a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts index cc6dc16cde..608fd5fb4a 100644 --- a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -7,6 +7,7 @@ export class ExpandedFormPage extends BasePage { readonly addNewTableButton: Locator; readonly copyUrlButton: Locator; readonly toggleCommentsButton: Locator; + readonly moreOptionsButton: Locator; constructor(dashboard: DashboardPage) { super(dashboard.rootPage); @@ -14,12 +15,44 @@ export class ExpandedFormPage extends BasePage { this.addNewTableButton = this.dashboard.get().locator('.nc-add-new-table'); this.copyUrlButton = this.dashboard.get().locator('.nc-copy-row-url:visible'); this.toggleCommentsButton = this.dashboard.get().locator('.nc-toggle-comments:visible'); + this.moreOptionsButton = this.dashboard.get().locator('.nc-actions-menu-btn:visible').last(); } get() { return this.dashboard.get().locator(`.nc-drawer-expanded-form`); } + async clickDuplicateRow() { + await this.moreOptionsButton.click(); + // wait for the menu to appear + await this.rootPage.waitForTimeout(1000); + await this.rootPage.locator('.nc-menu-item:has-text("Duplicate Row")').click(); + + // wait for loader to disappear + // await this.dashboard.waitForLoaderToDisappear(); + await this.rootPage.waitForTimeout(2000); + } + + async clickDeleteRow() { + await this.moreOptionsButton.click(); + // wait for the menu to appear + await this.rootPage.waitForTimeout(1000); + await this.rootPage.locator('.nc-menu-item:has-text("Delete Row")').click(); + await this.rootPage.locator('.ant-btn-primary:has-text("OK")').click(); + } + + async isDisabledDuplicateRow() { + await this.moreOptionsButton.click(); + const isDisabled = await this.rootPage.locator('.nc-menu-item.disabled:has-text("Duplicate Row")'); + return await isDisabled.count(); + } + + async isDisabledDeleteRow() { + await this.moreOptionsButton.click(); + const isDisabled = await this.rootPage.locator('.nc-menu-item.disabled:has-text("Delete Row")'); + return await isDisabled.count(); + } + async getShareRowUrl() { await this.copyUrlButton.click(); await this.verifyToast({ message: 'Copied to clipboard' }); diff --git a/tests/playwright/tests/expandedFormUrl.spec.ts b/tests/playwright/tests/expandedFormUrl.spec.ts index 8195920eca..d0863b85ac 100644 --- a/tests/playwright/tests/expandedFormUrl.spec.ts +++ b/tests/playwright/tests/expandedFormUrl.spec.ts @@ -1,8 +1,9 @@ -import { test } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import { DashboardPage } from '../pages/Dashboard'; import { GalleryPage } from '../pages/Dashboard/Gallery'; import { GridPage } from '../pages/Dashboard/Grid'; import setup from '../setup'; +import { ToolbarPage } from '../pages/Dashboard/common/Toolbar'; test.describe('Expanded form URL', () => { let dashboard: DashboardPage; @@ -132,3 +133,48 @@ test.describe('Expanded form URL', () => { await viewTestTestTable('gallery'); }); }); + +test.describe('Expanded record duplicate & delete options', () => { + let dashboard: DashboardPage, toolbar: ToolbarPage; + let context: any; + + test.beforeEach(async ({ page }) => { + context = await setup({ page }); + dashboard = new DashboardPage(page, context.project); + toolbar = dashboard.grid.toolbar; + }); + + test('Grid', async () => { + await dashboard.closeTab({ title: 'Team & Auth' }); + await dashboard.treeView.openTable({ title: 'Actor' }); + + // create filter to narrow down the number of records + await toolbar.clickFilter(); + await toolbar.filter.add({ + columnTitle: 'FirstName', + opType: 'is equal', + value: 'NICK', + isLocallySaved: false, + }); + await toolbar.clickFilter(); + + await dashboard.grid.verifyRowCount({ count: 3 }); + + // expand row & duplicate + await dashboard.grid.openExpandedRow({ index: 0 }); + await dashboard.expandedForm.clickDuplicateRow(); + await dashboard.expandedForm.save(); + await dashboard.grid.verifyRowCount({ count: 4 }); + + // expand row & delete + await dashboard.grid.openExpandedRow({ index: 3 }); + await dashboard.expandedForm.clickDeleteRow(); + await dashboard.grid.verifyRowCount({ count: 3 }); + + // expand row, duplicate & verify menu + await dashboard.grid.openExpandedRow({ index: 0 }); + await dashboard.expandedForm.clickDuplicateRow(); + expect(await dashboard.expandedForm.isDisabledDeleteRow()).toBe(1); + expect(await dashboard.expandedForm.isDisabledDuplicateRow()).toBe(1); + }); +});