|
|
|
@ -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')); |
|
|
|
|