Browse Source

fix: Fixed project opration test issue where we are not waiting for project duplication

pull/6414/head
Muhammed Mustafa 1 year ago
parent
commit
5fd9e8d70f
  1. 2
      tests/playwright/pages/Dashboard/TreeView.ts
  2. 6
      tests/playwright/setup/index.ts
  3. 34
      tests/playwright/tests/db/general/projectOperations.spec.ts

2
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);
}
}

6
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);

34
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<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);
}
}
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'));

Loading…
Cancel
Save