Browse Source

test: reset exp

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
test/reset-fail
Raju Udava 1 year ago
parent
commit
8d8ba99ab7
  1. 6
      .run/test-debug.run.xml
  2. 40
      tests/playwright/setup/xcdbProject.ts
  3. 310
      tests/playwright/tests/db/metaLTAR.spec.ts

6
.run/test-debug.run.xml

@ -3,10 +3,12 @@
<package-json value="$PROJECT_DIR$/tests/playwright/package.json" /> <package-json value="$PROJECT_DIR$/tests/playwright/package.json" />
<command value="run" /> <command value="run" />
<scripts> <scripts>
<script value="test:debug" /> <script value="test:debug:intelliJ" />
</scripts> </scripts>
<node-interpreter value="project" /> <node-interpreter value="project" />
<envs /> <envs>
<env name="E2E_DEV_DB_TYPE" value="sqlite" />
</envs>
<method v="2" /> <method v="2" />
</configuration> </configuration>
</component> </component>

40
tests/playwright/setup/xcdbProject.ts

@ -0,0 +1,40 @@
import { Api } from 'nocodb-sdk';
let api: Api;
async function createXcdb(token?: string) {
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': token,
},
});
const projectList = await api.project.list();
for (const project of projectList.list) {
// delete project with title 'xcdb' if it exists
if (project.title === 'xcdb') {
await api.project.delete(project.id);
}
}
const project = await api.project.create({ title: 'xcdb' });
return project;
}
async function deleteXcdb(token?: string) {
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': token,
},
});
const projectList = await api.project.list();
for (const project of projectList.list) {
// delete project with title 'xcdb' if it exists
if (project.title === 'xcdb') {
await api.project.delete(project.id);
}
}
}
export { createXcdb, deleteXcdb };

310
tests/playwright/tests/db/metaLTAR.spec.ts

@ -24,20 +24,42 @@ import setup from '../../setup';
import { Api, UITypes } from 'nocodb-sdk'; import { Api, UITypes } from 'nocodb-sdk';
import { DashboardPage } from '../../pages/Dashboard'; import { DashboardPage } from '../../pages/Dashboard';
import { GridPage } from '../../pages/Dashboard/Grid'; import { GridPage } from '../../pages/Dashboard/Grid';
import { createXcdb, deleteXcdb } from '../../setup/xcdbProject';
import { ProjectsPage } from '../../pages/ProjectsPage';
import { isSqlite } from '../../setup/db';
let api: Api<any>; let api: Api<any>;
const recordCount = 10; const recordCount = 10;
test.describe('Test table', () => { test.describe.only('Test table', () => {
let context: any; let context: any;
let dashboard: DashboardPage; let dashboard: DashboardPage;
let grid: GridPage; let grid: GridPage;
const tables = []; const tables = [];
test.afterEach(async () => {
try {
if (context) {
await deleteXcdb(context.token);
}
} catch (e) {
console.log(e);
}
// reset tables array
tables.length = 0;
});
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
context = await setup({ page, isEmptyProject: true }); context = await setup({ page, isEmptyProject: true });
dashboard = new DashboardPage(page, context.project); dashboard = new DashboardPage(page, context.project);
grid = dashboard.grid; grid = dashboard.grid;
// create a new xcdb project
const xcdb = await createXcdb(context.token);
await dashboard.clickHome();
const projectsPage = new ProjectsPage(dashboard.rootPage);
await projectsPage.openProject({ title: 'xcdb', withoutPrefix: true });
api = new Api({ api = new Api({
baseURL: `http://localhost:8080/`, baseURL: `http://localhost:8080/`,
headers: { headers: {
@ -68,16 +90,16 @@ test.describe('Test table', () => {
} }
// Create tables // Create tables
const project = await api.project.read(context.project.id); // const project = await api.project.read(xcdb.id);
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
const table = await api.base.tableCreate(context.project.id, project.bases?.[0].id, { const table = await api.base.tableCreate(xcdb.id, xcdb.bases?.[0].id, {
table_name: `Table${i}`, table_name: `Table${i}`,
title: `Table${i}`, title: `Table${i}`,
columns: columns, columns: columns,
}); });
tables.push(table); tables.push(table);
await api.dbTableRow.bulkCreate('noco', context.project.id, tables[i].id, rows); await api.dbTableRow.bulkCreate('noco', xcdb.id, tables[i].id, rows);
} }
// Create links // Create links
@ -90,181 +112,113 @@ test.describe('Test table', () => {
childId: tables[1].id, childId: tables[1].id,
type: 'hm', type: 'hm',
}); });
await api.dbTableColumn.create(tables[1].id, { // await api.dbTableColumn.create(tables[1].id, {
uidt: UITypes.LinkToAnotherRecord, // uidt: UITypes.LinkToAnotherRecord,
title: `TableB:hm:TableC`, // title: `TableB:hm:TableC`,
column_name: `TableB:hm:TableC`, // column_name: `TableB:hm:TableC`,
parentId: tables[1].id, // parentId: tables[1].id,
childId: tables[2].id, // childId: tables[2].id,
type: 'hm', // type: 'hm',
}); // });
//
// TableA <mm> TableD <mm> TableE // // TableA <mm> TableD <mm> TableE
await api.dbTableColumn.create(tables[0].id, { // await api.dbTableColumn.create(tables[0].id, {
uidt: UITypes.LinkToAnotherRecord, // uidt: UITypes.LinkToAnotherRecord,
title: `TableA:mm:TableD`, // title: `TableA:mm:TableD`,
column_name: `TableA:mm:TableD`, // column_name: `TableA:mm:TableD`,
parentId: tables[0].id, // parentId: tables[0].id,
childId: tables[3].id, // childId: tables[3].id,
type: 'mm', // type: 'mm',
}); // });
await api.dbTableColumn.create(tables[3].id, { // await api.dbTableColumn.create(tables[3].id, {
uidt: UITypes.LinkToAnotherRecord, // uidt: UITypes.LinkToAnotherRecord,
title: `TableD:mm:TableE`, // title: `TableD:mm:TableE`,
column_name: `TableD:mm:TableE`, // column_name: `TableD:mm:TableE`,
parentId: tables[3].id, // parentId: tables[3].id,
childId: tables[4].id, // childId: tables[4].id,
type: 'mm', // type: 'mm',
}); // });
//
// TableA <hm> TableA : self relation // // TableA <hm> TableA : self relation
await api.dbTableColumn.create(tables[0].id, { // await api.dbTableColumn.create(tables[0].id, {
uidt: UITypes.LinkToAnotherRecord, // uidt: UITypes.LinkToAnotherRecord,
title: `TableA:hm:TableA`, // title: `TableA:hm:TableA`,
column_name: `TableA:hm:TableA`, // column_name: `TableA:hm:TableA`,
parentId: tables[0].id, // parentId: tables[0].id,
childId: tables[0].id, // childId: tables[0].id,
type: 'hm', // type: 'hm',
}); // });
//
// TableA <mm> TableA : self relation // // TableA <mm> TableA : self relation
await api.dbTableColumn.create(tables[0].id, { // await api.dbTableColumn.create(tables[0].id, {
uidt: UITypes.LinkToAnotherRecord, // uidt: UITypes.LinkToAnotherRecord,
title: `TableA:mm:TableA`, // title: `TableA:mm:TableA`,
column_name: `TableA:mm:TableA`, // column_name: `TableA:mm:TableA`,
parentId: tables[0].id, // parentId: tables[0].id,
childId: tables[0].id, // childId: tables[0].id,
type: 'mm', // type: 'mm',
}); // });
//
// Add links // // Add links
// TableA <hm> TableB <hm> TableC // // TableA <hm> TableB <hm> TableC
// Link every record in tableA to 3 records in tableB // // Link every record in tableA to 3 records in tableB
for (let i = 1; i <= recordCount; i++) { // for (let i = 1; i <= recordCount; i++) {
await api.dbTableRow.nestedAdd( // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableB', `${i * 3 - 2}`);
'noco', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableB', `${i * 3 - 1}`);
context.project.id, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableB', `${i * 3 - 0}`);
tables[0].id, // }
i, // // Link every record in tableB to 3 records in tableC
'hm', // for (let i = 1; i <= recordCount; i++) {
'TableA:hm:TableB', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[1].id, i, 'hm', 'TableB:hm:TableC', `${i * 3 - 2}`);
`${i * 3 - 2}` // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[1].id, i, 'hm', 'TableB:hm:TableC', `${i * 3 - 1}`);
); // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[1].id, i, 'hm', 'TableB:hm:TableC', `${i * 3 - 0}`);
await api.dbTableRow.nestedAdd( // }
'noco', //
context.project.id, // // TableA <mm> TableD <mm> TableE
tables[0].id, // // Link every record in tableA to 5 records in tableD
i, // for (let i = 1; i <= recordCount; i++) {
'hm', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i}`);
'TableA:hm:TableB', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 1}`);
`${i * 3 - 1}` // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 2}`);
); // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 3}`);
await api.dbTableRow.nestedAdd( // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 4}`);
'noco', // }
context.project.id, // // Link every record in tableD to 5 records in tableE
tables[0].id, // for (let i = 1; i <= recordCount; i++) {
i, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i}`);
'hm', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 1}`);
'TableA:hm:TableB', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 2}`);
`${i * 3 - 0}` // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 3}`);
); // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 4}`);
} // }
// Link every record in tableB to 3 records in tableC //
for (let i = 1; i <= recordCount; i++) { // // TableA <hm> TableA : self relation
await api.dbTableRow.nestedAdd( // // Link every record in tableA to 3 records in tableA
'noco', // for (let i = 1; i <= recordCount; i++) {
context.project.id, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableA', `${i * 3 - 2}`);
tables[1].id, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableA', `${i * 3 - 1}`);
i, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'hm', 'TableA:hm:TableA', `${i * 3 - 0}`);
'hm', // }
'TableB:hm:TableC', //
`${i * 3 - 2}` // // TableA <mm> TableA : self relation
); // // Link every record in tableA to 5 records in tableA
await api.dbTableRow.nestedAdd( // for (let i = 1; i <= recordCount; i++) {
'noco', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i}`);
context.project.id, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 1}`);
tables[1].id, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 2}`);
i, // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 3}`);
'hm', // await api.dbTableRow.nestedAdd('noco', xcdb.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 4}`);
'TableB:hm:TableC', // }
`${i * 3 - 1}`
);
await api.dbTableRow.nestedAdd(
'noco',
context.project.id,
tables[1].id,
i,
'hm',
'TableB:hm:TableC',
`${i * 3 - 0}`
);
}
// TableA <mm> TableD <mm> TableE
// Link every record in tableA to 5 records in tableD
for (let i = 1; i <= recordCount; i++) {
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 1}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 2}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 3}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableD', `${i + 4}`);
}
// Link every record in tableD to 5 records in tableE
for (let i = 1; i <= recordCount; i++) {
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 1}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 2}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 3}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[3].id, i, 'mm', 'TableD:mm:TableE', `${i + 4}`);
}
// TableA <hm> TableA : self relation
// Link every record in tableA to 3 records in tableA
for (let i = 1; i <= recordCount; i++) {
await api.dbTableRow.nestedAdd(
'noco',
context.project.id,
tables[0].id,
i,
'hm',
'TableA:hm:TableA',
`${i * 3 - 2}`
);
await api.dbTableRow.nestedAdd(
'noco',
context.project.id,
tables[0].id,
i,
'hm',
'TableA:hm:TableA',
`${i * 3 - 1}`
);
await api.dbTableRow.nestedAdd(
'noco',
context.project.id,
tables[0].id,
i,
'hm',
'TableA:hm:TableA',
`${i * 3 - 0}`
);
}
// TableA <mm> TableA : self relation
// Link every record in tableA to 5 records in tableA
for (let i = 1; i <= recordCount; i++) {
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 1}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 2}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 3}`);
await api.dbTableRow.nestedAdd('noco', context.project.id, tables[0].id, i, 'mm', 'TableA:mm:TableA', `${i + 4}`);
}
// refresh page // refresh page
await page.reload(); await page.reload();
}); });
test('Delete record - single, over UI', async () => { test('Delete record - single, over UI', async () => {
if (isSqlite(context)) {
return;
}
await dashboard.treeView.openTable({ title: 'Table0' }); await dashboard.treeView.openTable({ title: 'Table0' });
await grid.deleteRow(0); await grid.deleteRow(0);
@ -279,6 +233,10 @@ test.describe('Test table', () => {
}); });
test('Delete record - bulk, over UI', async () => { test('Delete record - bulk, over UI', async () => {
if (isSqlite(context)) {
return;
}
await dashboard.treeView.openTable({ title: 'Table0' }); await dashboard.treeView.openTable({ title: 'Table0' });
await grid.selectRow(0); await grid.selectRow(0);
await grid.selectRow(1); await grid.selectRow(1);
@ -296,6 +254,9 @@ test.describe('Test table', () => {
}); });
test('Delete column', async () => { test('Delete column', async () => {
if (isSqlite(context)) {
return;
}
// has-many // has-many
await dashboard.treeView.openTable({ title: 'Table0' }); await dashboard.treeView.openTable({ title: 'Table0' });
await dashboard.grid.column.delete({ title: 'TableA:hm:TableB' }); await dashboard.grid.column.delete({ title: 'TableA:hm:TableB' });
@ -338,6 +299,9 @@ test.describe('Test table', () => {
}); });
test('Delete table', async () => { test('Delete table', async () => {
if (isSqlite(context)) {
return;
}
await dashboard.treeView.deleteTable({ title: 'Table0' }); await dashboard.treeView.deleteTable({ title: 'Table0' });
await dashboard.treeView.verifyTable({ title: 'Table0', exists: false }); await dashboard.treeView.verifyTable({ title: 'Table0', exists: false });

Loading…
Cancel
Save