π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
add more base error handling
Fendy Heryanto3b4623e3af02
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/base.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/base.test.tsindex 8252a96e9b..2dcb1e5f72 100644--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/base.test.ts+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/base.test.ts@@ -187,5 +187,81 @@ export default function () {expect(result.body.message).to.eq(`Base 'NOT_FOUND_BASE' not found`);});});++ describe('base get', () => {+ it('will get non existed base', async () => {+ const result = await request(context.app)+ .get(`/api/v3/meta/bases/NOT_FOUND_BASE`)+ .set('xc-token', context.xc_token)+ .expect(422);+ expect(result.body.error).to.eq('BASE_NOT_FOUND');+ expect(result.body.message).to.eq(`Base 'NOT_FOUND_BASE' not found`);+ });+ });++ describe('base update', () => {+ let API_PREFIX = '/api/v3/meta/workspaces';+ let initBase: any;+ beforeEach(async () => {+ const workspaceId = context.fk_workspace_id;+ const baseResult = await request(context.app)+ .post(`/api/v3/meta/workspaces/${workspaceId}/bases`)+ .set('xc-token', context.xc_token)+ .send({+ title: 'MyBase',+ })+ .expect(200);+ initBase = baseResult.body;+ API_PREFIX = `/api/v3/meta/bases/${initBase.id}`;+ });++ it('will update not existed base', async () => {+ const result = await request(context.app)+ .patch(`/api/v3/meta/bases/NOT_FOUND_BASE`)+ .set('xc-token', context.xc_token)+ .send({+ title: 'HELLO',+ })+ .expect(422);+ expect(result.body.error).to.eq('BASE_NOT_FOUND');+ expect(result.body.message).to.eq(`Base 'NOT_FOUND_BASE' not found`);+ });++ it('will update empty title', async () => {+ const result = await request(context.app)+ .patch(`${API_PREFIX}`)+ .set('xc-token', context.xc_token)+ .send({+ title: '',+ })+ .expect(400);+ expect(result.body.error).to.eq('INVALID_REQUEST_BODY');+ expect(result.body.message).to.eq(`Invalid request body`);+ });+ });++ describe('base delete', () => {+ let initBase: any;+ beforeEach(async () => {+ const workspaceId = context.fk_workspace_id;+ const baseResult = await request(context.app)+ .post(`/api/v3/meta/workspaces/${workspaceId}/bases`)+ .set('xc-token', context.xc_token)+ .send({+ title: 'MyBase',+ })+ .expect(200);+ initBase = baseResult.body;+ });++ it('will delete not existed base', async () => {+ const result = await request(context.app)+ .delete(`/api/v3/meta/bases/NOT_FOUND_BASE`)+ .set('xc-token', context.xc_token)+ .expect(422);+ expect(result.body.error).to.eq('BASE_NOT_FOUND');+ expect(result.body.message).to.eq(`Base 'NOT_FOUND_BASE' not found`);+ });+ });});}