Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

add positive case for column v3

Fendy Heryanto9aaf100b751f
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/column.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/column.test.ts
new file mode 100644
index 0000000000..97b6277537
--- /dev/null
+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/column.test.ts
@@ -0,0 +1,50 @@
+import 'mocha';
+import { expect } from 'chai';
+import request from 'supertest';
+import init from '../../../init';
+
+export default function () {
+ describe('Column v3', () => {
+ let context: Awaited<ReturnType<typeof init>>;
+ let initBase: any;
+ let API_PREFIX: string;
+ let table: any;
+
+ beforeEach(async () => {
+ context = await init();
+ 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}`;
+ // create a table for column tests
+ const tableResult = await request(context.app)
+ .post(`${API_PREFIX}/tables`)
+ .set('xc-token', context.xc_token)
+ .send({ title: 'MyTable' })
+ .expect(200);
+ table = tableResult.body;
+ });
+
+ describe('column create', () => {
+ it('will handle SingleLineText field', async () => {
+ const result = await request(context.app)
+ .post(`${API_PREFIX}/tables/${table.id}/fields`)
+ .set('xc-token', context.xc_token)
+ .send({ title: 'FSingleLineText', type: 'SingleLineText' })
+ .expect(200);
+ expect(result.body.id).to.not.empty;
+
+ const getResult = await request(context.app)
+ .get(`${API_PREFIX}/fields/${result.body.id}`)
+ .set('xc-token', context.xc_token)
+ .expect(200);
+ expect(getResult.body.id).to.eq(result.body.id);
+ expect(getResult.body.title).to.eq('FSingleLineText');
+ });
+ });
+ });
+}
diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/index.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/index.test.ts
index efb8ad4065..7fbd1abdca 100644
--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/index.test.ts
+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/index.test.ts
@@ -1,5 +1,6 @@
import baseTestV3 from './base.test';
import tableTestV3 from './table.test';
+import columnTestV3 from './column.test';
import baseUsersTestV3 from './baseUsers.test';
import errorHandlingMetaTestsV3 from './error-handling/index.test';
import workspaceUsersTest from './workspaceUsers.test';
@@ -8,6 +9,7 @@ export default function () {
baseTestV3();
baseUsersTestV3();
tableTestV3();
+ columnTestV3();
errorHandlingMetaTestsV3();
workspaceUsersTest();
}