Browse Source

refactor/Added unit test for view row api

pull/3358/head
Muhammed Mustafa 2 years ago
parent
commit
31d2fa4378
  1. 1
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  2. 29
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

1
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -47,6 +47,7 @@ async function dataCount(req: Request, res: Response) {
res.json({ count });
}
// todo: Handle the error case where view doesnt belong to model
async function dataInsert(req: Request, res: Response) {
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req);

29
packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

@ -511,6 +511,35 @@ function viewRowTests() {
it('Create table row form', async function () {
await testCreateRowView(ViewTypes.FORM);
});
const testCreateRowViewWithWrongView = async (viewType: ViewTypes) => {
const table = await createTable(context, project);
const nonRelatedView = await createView(context, {
title: 'View',
table: customerTable,
type: viewType
});
await request(context.app)
.post(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}`)
.set('xc-auth', context.token)
.send({
title: 'Test',
})
.expect(400);
}
it('Create table row grid wrong grid id', async function () {
await testCreateRowViewWithWrongView(ViewTypes.GRID);
});
it('Create table row wrong gallery id', async function () {
await testCreateRowViewWithWrongView(ViewTypes.GALLERY);
});
it('Create table row wrong form id', async function () {
await testCreateRowViewWithWrongView(ViewTypes.FORM);
});
}
export default function () {

Loading…
Cancel
Save