diff --git a/tests/playwright/pages/Dashboard/TreeView.ts b/tests/playwright/pages/Dashboard/TreeView.ts index e2fd313968..54b0e66da0 100644 --- a/tests/playwright/pages/Dashboard/TreeView.ts +++ b/tests/playwright/pages/Dashboard/TreeView.ts @@ -354,5 +354,7 @@ export class TreeViewPage extends BasePage { await contextMenu.locator(`.ant-dropdown-menu-item:has-text("Duplicate")`).click(); await this.rootPage.locator('div.ant-modal-content').locator(`button.ant-btn:has-text("Confirm")`).click(); + + await this.rootPage.waitForTimeout(10000); } } diff --git a/tests/playwright/setup/index.ts b/tests/playwright/setup/index.ts index 74ab994e64..91ad7c6910 100644 --- a/tests/playwright/setup/index.ts +++ b/tests/playwright/setup/index.ts @@ -219,7 +219,11 @@ async function localInit({ const projects = await api.workspaceProject.list(w.id); for (const project of projects.list) { - await api.project.delete(project.id); + try { + await api.project.delete(project.id); + } catch (e) { + console.log(`Error deleting project: ws delete`, project); + } } await api['workspace'].delete(w.id); diff --git a/tests/playwright/tests/db/general/projectOperations.spec.ts b/tests/playwright/tests/db/general/projectOperations.spec.ts index 92b153c64e..7683ed4117 100644 --- a/tests/playwright/tests/db/general/projectOperations.spec.ts +++ b/tests/playwright/tests/db/general/projectOperations.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from '@playwright/test'; import { DashboardPage } from '../../../pages/Dashboard'; import { airtableApiBase, airtableApiKey } from '../../../constants'; -import setup, { unsetup } from '../../../setup'; +import setup, { NcContext, unsetup } from '../../../setup'; import { Api, ProjectListType } from 'nocodb-sdk'; import { ProjectInfo, ProjectInfoApiUtil } from '../../../tests/utils/projectInfoApiUtil'; import { deepCompare } from '../../../tests/utils/objectCompareUtil'; @@ -9,33 +9,20 @@ import { isEE } from '../../../setup/db'; test.describe('Project operations', () => { let dashboard: DashboardPage; - let context: any; + let context: NcContext; let api: Api; test.setTimeout(100000); - async function getProjectList() { + async function getProjectList(workspaceId: string) { let projectList: ProjectListType; if (isEE() && api['workspaceProject']) { - const ws = await api['workspace'].list(); - projectList = await api['workspaceProject'].list(ws.list[1].id); + projectList = await api['workspaceProject'].list(workspaceId); } else { projectList = await api.project.list(); } + return projectList; } - async function deleteIfExists(name: string) { - try { - const projectList = await getProjectList(); - - const project = projectList.list.find((p: any) => p.title === name); - if (project) { - await api.project.delete(project.id); - console.log('deleted project: ', project.id); - } - } catch (e) { - console.log('Error: ', e); - } - } async function createTestProjectWithData(testProjectName: string) { await dashboard.leftSidebar.createProject({ title: testProjectName }); @@ -71,9 +58,6 @@ test.describe('Project operations', () => { }); test('rename, delete', async () => { - // if project already exists, delete it - await deleteIfExists('project-firstName'); - await dashboard.leftSidebar.createProject({ title: 'project-firstName' }); await dashboard.treeView.renameProject({ title: 'project-firstName', newTitle: 'project-rename' }); await dashboard.treeView.openProject({ title: 'project-rename' }); @@ -82,10 +66,8 @@ test.describe('Project operations', () => { test('project_duplicate', async () => { // if project already exists, delete it to avoid test failures due to residual data - const testProjectName = 'Project-To-Import-Export'; - const dupeProjectName: string = testProjectName + ' copy'; - await deleteIfExists(testProjectName); - await deleteIfExists(dupeProjectName); + const random = Math.floor(Math.random() * 1000000); + const testProjectName = `Project-To-Import-Export-${random}`; // // data creation for original test project await createTestProjectWithData(testProjectName); @@ -95,7 +77,7 @@ test.describe('Project operations', () => { await dashboard.treeView.openProject({ title: testProjectName }); // compare - const projectList = await getProjectList(); + const projectList = await getProjectList(context.workspace.id); const testProjectId = projectList.list.find((p: any) => p.title === testProjectName); const dupeProjectId = projectList.list.find((p: any) => p.title.startsWith(testProjectName + ' copy'));