|
|
@ -1,7 +1,7 @@ |
|
|
|
import { expect, test } from '@playwright/test'; |
|
|
|
import { expect, test } from '@playwright/test'; |
|
|
|
import { DashboardPage } from '../../../pages/Dashboard'; |
|
|
|
import { DashboardPage } from '../../../pages/Dashboard'; |
|
|
|
import { airtableApiBase, airtableApiKey } from '../../../constants'; |
|
|
|
import { airtableApiBase, airtableApiKey } from '../../../constants'; |
|
|
|
import setup, { unsetup } from '../../../setup'; |
|
|
|
import setup, { NcContext, unsetup } from '../../../setup'; |
|
|
|
import { Api, ProjectListType } from 'nocodb-sdk'; |
|
|
|
import { Api, ProjectListType } from 'nocodb-sdk'; |
|
|
|
import { ProjectInfo, ProjectInfoApiUtil } from '../../../tests/utils/projectInfoApiUtil'; |
|
|
|
import { ProjectInfo, ProjectInfoApiUtil } from '../../../tests/utils/projectInfoApiUtil'; |
|
|
|
import { deepCompare } from '../../../tests/utils/objectCompareUtil'; |
|
|
|
import { deepCompare } from '../../../tests/utils/objectCompareUtil'; |
|
|
@ -9,33 +9,20 @@ import { isEE } from '../../../setup/db'; |
|
|
|
|
|
|
|
|
|
|
|
test.describe('Project operations', () => { |
|
|
|
test.describe('Project operations', () => { |
|
|
|
let dashboard: DashboardPage; |
|
|
|
let dashboard: DashboardPage; |
|
|
|
let context: any; |
|
|
|
let context: NcContext; |
|
|
|
let api: Api<any>; |
|
|
|
let api: Api<any>; |
|
|
|
test.setTimeout(100000); |
|
|
|
test.setTimeout(100000); |
|
|
|
|
|
|
|
|
|
|
|
async function getProjectList() { |
|
|
|
async function getProjectList(workspaceId: string) { |
|
|
|
let projectList: ProjectListType; |
|
|
|
let projectList: ProjectListType; |
|
|
|
if (isEE() && api['workspaceProject']) { |
|
|
|
if (isEE() && api['workspaceProject']) { |
|
|
|
const ws = await api['workspace'].list(); |
|
|
|
projectList = await api['workspaceProject'].list(workspaceId); |
|
|
|
projectList = await api['workspaceProject'].list(ws.list[1].id); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
projectList = await api.project.list(); |
|
|
|
projectList = await api.project.list(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return projectList; |
|
|
|
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) { |
|
|
|
async function createTestProjectWithData(testProjectName: string) { |
|
|
|
await dashboard.leftSidebar.createProject({ title: testProjectName }); |
|
|
|
await dashboard.leftSidebar.createProject({ title: testProjectName }); |
|
|
@ -71,9 +58,6 @@ test.describe('Project operations', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('rename, delete', async () => { |
|
|
|
test('rename, delete', async () => { |
|
|
|
// if project already exists, delete it
|
|
|
|
|
|
|
|
await deleteIfExists('project-firstName'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await dashboard.leftSidebar.createProject({ title: 'project-firstName' }); |
|
|
|
await dashboard.leftSidebar.createProject({ title: 'project-firstName' }); |
|
|
|
await dashboard.treeView.renameProject({ title: 'project-firstName', newTitle: 'project-rename' }); |
|
|
|
await dashboard.treeView.renameProject({ title: 'project-firstName', newTitle: 'project-rename' }); |
|
|
|
await dashboard.treeView.openProject({ title: 'project-rename' }); |
|
|
|
await dashboard.treeView.openProject({ title: 'project-rename' }); |
|
|
@ -82,10 +66,8 @@ test.describe('Project operations', () => { |
|
|
|
|
|
|
|
|
|
|
|
test('project_duplicate', async () => { |
|
|
|
test('project_duplicate', async () => { |
|
|
|
// if project already exists, delete it to avoid test failures due to residual data
|
|
|
|
// if project already exists, delete it to avoid test failures due to residual data
|
|
|
|
const testProjectName = 'Project-To-Import-Export'; |
|
|
|
const random = Math.floor(Math.random() * 1000000); |
|
|
|
const dupeProjectName: string = testProjectName + ' copy'; |
|
|
|
const testProjectName = `Project-To-Import-Export-${random}`; |
|
|
|
await deleteIfExists(testProjectName); |
|
|
|
|
|
|
|
await deleteIfExists(dupeProjectName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // data creation for original test project
|
|
|
|
// // data creation for original test project
|
|
|
|
await createTestProjectWithData(testProjectName); |
|
|
|
await createTestProjectWithData(testProjectName); |
|
|
@ -95,7 +77,7 @@ test.describe('Project operations', () => { |
|
|
|
await dashboard.treeView.openProject({ title: testProjectName }); |
|
|
|
await dashboard.treeView.openProject({ title: testProjectName }); |
|
|
|
|
|
|
|
|
|
|
|
// compare
|
|
|
|
// compare
|
|
|
|
const projectList = await getProjectList(); |
|
|
|
const projectList = await getProjectList(context.workspace.id); |
|
|
|
|
|
|
|
|
|
|
|
const testProjectId = projectList.list.find((p: any) => p.title === testProjectName); |
|
|
|
const testProjectId = projectList.list.find((p: any) => p.title === testProjectName); |
|
|
|
const dupeProjectId = projectList.list.find((p: any) => p.title.startsWith(testProjectName + ' copy')); |
|
|
|
const dupeProjectId = projectList.list.find((p: any) => p.title.startsWith(testProjectName + ' copy')); |
|
|
|