mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 03:25:45 +00:00
fix: Fixed project opration test issue where we are not waiting for project duplication
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,32 +9,19 @@ import { isEE } from '../../../setup/db';
|
||||
|
||||
test.describe('Project operations', () => {
|
||||
let dashboard: DashboardPage;
|
||||
let context: any;
|
||||
let context: NcContext;
|
||||
let api: Api<any>;
|
||||
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);
|
||||
}
|
||||
return projectList;
|
||||
}
|
||||
|
||||
async function createTestProjectWithData(testProjectName: string) {
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user