Browse Source

add playwright test for project duplicate

and airtable import
feat/export-nest
starbirdtech383 2 years ago committed by mertmit
parent
commit
cae19f331a
  1. 66
      tests/playwright/tests/db/projectOperations.spec.ts

66
tests/playwright/tests/db/projectOperations.spec.ts

@ -1,5 +1,7 @@
import { test } from '@playwright/test';
import { DashboardPage } from '../../pages/Dashboard';
import { airtableApiBase, airtableApiKey } from '../../constants';
import { quickVerify } from '../../quickTests/commonTest';
import setup from '../../setup';
import { ToolbarPage } from '../../pages/Dashboard/common/Toolbar';
import { ProjectsPage } from '../../pages/ProjectsPage';
@ -11,8 +13,23 @@ test.describe('Project operations', () => {
let context: any;
let api: Api<any>;
let projectPage: ProjectsPage;
test.setTimeout(150000);
async function deleteIfExists(name: string) {
try {
const projectList = await api.project.list();
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);
}
}
test.beforeEach(async ({ page }) => {
page.setDefaultTimeout(70000);
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
projectPage = new ProjectsPage(page);
@ -28,16 +45,7 @@ test.describe('Project operations', () => {
test('rename, delete', async () => {
// if project already exists, delete it
try {
const projectList = await api.project.list();
const project = projectList.list.find((p: any) => p.title === 'project-firstName');
if (project) {
await api.project.delete(project.id);
console.log('deleted project: ', project.id);
}
} catch (e) {
console.log('Error: ', e);
}
await deleteIfExists('project-firstName');
await dashboard.clickHome();
await projectPage.createProject({ name: 'project-firstName', withoutPrefix: true });
@ -52,4 +60,42 @@ test.describe('Project operations', () => {
await dashboard.clickHome();
await projectPage.deleteProject({ title: 'project-rename', withoutPrefix: true });
});
test.only('project_duplicate', async () => {
// if project already exists, delete it to avoid test failures due to residual data
const testProjectName = 'project-to-imexp';
const dupeProjectName: string = testProjectName + ' copy';
await deleteIfExists(testProjectName);
await deleteIfExists(dupeProjectName);
// // data creation for orginial test project
await createTestProjectWithData();
// create duplicate
await dashboard.clickHome();
await projectPage.duplicateProject({ name: testProjectName, withoutPrefix: true });
await projectPage.openProject({ title: dupeProjectName, withoutPrefix: true });
await quickVerify({ dashboard, airtableImport: true, context });
// cleanup test-data
await cleanupTestData();
async function createTestProjectWithData() {
await dashboard.clickHome();
await projectPage.createProject({ name: testProjectName, withoutPrefix: true });
await dashboard.treeView.quickImport({ title: 'Airtable' });
await dashboard.importAirtable.import({
key: airtableApiKey,
baseId: airtableApiBase,
});
await dashboard.rootPage.waitForTimeout(1000);
await quickVerify({ dashboard, airtableImport: true, context });
}
async function cleanupTestData() {
await dashboard.clickHome();
await projectPage.deleteProject({ title: dupeProjectName, withoutPrefix: true });
await projectPage.deleteProject({ title: testProjectName, withoutPrefix: true });
}
});
});

Loading…
Cancel
Save