From 9592ebcac2d71fcfa2b1359cfef2e66a769f8083 Mon Sep 17 00:00:00 2001 From: starbirdtech383 Date: Wed, 10 May 2023 23:22:37 +0530 Subject: [PATCH] update playwright tests to take care of model changes in duplicate confirmation --- tests/playwright/pages/Dashboard/TreeView.ts | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/playwright/pages/Dashboard/TreeView.ts b/tests/playwright/pages/Dashboard/TreeView.ts index 9a8bb1870f..4ac6cbd8f2 100644 --- a/tests/playwright/pages/Dashboard/TreeView.ts +++ b/tests/playwright/pages/Dashboard/TreeView.ts @@ -174,6 +174,33 @@ export class TreeViewPage extends BasePage { ).toHaveCount(1); } + async duplicateTable(title: string, includeData = true, includeViews = true) { + await this.get().locator(`.nc-project-tree-tbl-${title}`).click({ button: 'right' }); + await this.dashboard.get().locator('div.nc-project-menu-item:has-text("Duplicate")').click(); + + // Find the checkbox element with the label "Include data" + const includeDataCheckbox = await this.dashboard.get().getByText('Include data', { exact: true }); + // Check the checkbox if it is not already checked + if ((await includeDataCheckbox.isChecked()) && !includeData) { + await includeDataCheckbox.click(); // click the checkbox to check it + } + + // Find the checkbox element with the label "Include data" + const includeViewsCheckbox = await this.dashboard.get().getByText('Include views', { exact: true }); + // Check the checkbox if it is not already checked + if ((await includeViewsCheckbox.isChecked()) && !includeViews) { + await includeViewsCheckbox.click(); // click the checkbox to check it + } + + await this.waitForResponse({ + uiAction: () => this.rootPage.getByRole('button', { name: 'Confirm' }).click(), + httpMethodsToMatch: ['POST'], + requestUrlPathToMatch: `/api/v1/db/meta/duplicate/`, + responseJsonMatcher: json => json.name === 'duplicate-model', + }); + await this.get().locator(`[data-testid="tree-view-table-${title} copy"]`).waitFor(); + } + async duplicateTable(title: string, includeData = true, includeViews = true) { await this.get().locator(`.nc-project-tree-tbl-${title}`).click({ button: 'right' }); await this.dashboard.get().locator('div.nc-project-menu-item:has-text("Duplicate")').click();