diff --git a/tests/playwright/pages/Dashboard/Grid/Column/index.ts b/tests/playwright/pages/Dashboard/Grid/Column/index.ts index 1116e886e5..b69be265a7 100644 --- a/tests/playwright/pages/Dashboard/Grid/Column/index.ts +++ b/tests/playwright/pages/Dashboard/Grid/Column/index.ts @@ -213,6 +213,14 @@ export class ColumnPageObject extends BasePage { } } + async duplicateColumn({ title, expectedTitle = `${title}_copy` }: { title: string; expectedTitle?: string }) { + await this.grid.get().locator(`th[data-title="${title}"] .nc-ui-dt-dropdown`).click(); + await this.rootPage.locator('li[role="menuitem"]:has-text("Duplicate"):visible').click(); + + await this.verifyToast({ message: 'Column duplicated successfully' }); + await this.grid.get().locator(`th[data-title="${expectedTitle}"]`).isVisible(); + } + async save({ isUpdated }: { isUpdated?: boolean } = {}) { await this.waitForResponse({ uiAction: this.get().locator('button:has-text("Save")').click(), diff --git a/tests/playwright/tests/columnDuplicate.spec.ts b/tests/playwright/tests/columnDuplicate.spec.ts new file mode 100644 index 0000000000..ce3b8b1006 --- /dev/null +++ b/tests/playwright/tests/columnDuplicate.spec.ts @@ -0,0 +1,69 @@ +import { test } from '@playwright/test'; +import { DashboardPage } from '../pages/Dashboard'; +import setup from '../setup'; + +const columns = [ + { + title: 'SingleLineText', + type: 'SingleLineText', + }, + { + title: 'LongText', + type: 'LongText', + }, + // todo: Number column creation not works + // { + // title: 'Number', + // type: 'Number', + // }, + { + title: 'Decimal', + type: 'Decimal', + }, + { + title: 'Checkbox', + type: 'Checkbox', + }, + { + title: 'Email', + type: 'Email', + }, + { + title: 'PhoneNumber', + type: 'PhoneNumber', + }, + { + title: 'Url', + type: 'Url', + }, +]; + +test.describe('Duplicate column', () => { + let dashboard: DashboardPage; + let context: any; + + test.beforeEach(async ({ page }) => { + context = await setup({ page }); + dashboard = new DashboardPage(page, context.project); + }); + + test('Duplicate text field', async () => { + await dashboard.treeView.openTable({ title: 'Film' }); + + for (const { title, type } of columns) { + await dashboard.grid.column.create({ + title, + type, + }); + + await dashboard.grid.column.duplicateColumn({ + title, + }); + await dashboard.grid.column.duplicateColumn({ + title, + expectedTitle: `${title}_copy_1`, + }); + } + await dashboard.closeTab({ title: 'Film' }); + }); +});