π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
test unit for kanban
Fendy Heryanto94e18f649346
diff --git a/packages/nocodb/src/services/v3/views-v3.service.ts b/packages/nocodb/src/services/v3/views-v3.service.tsindex 17d2a8a686..874690550a 100644--- a/packages/nocodb/src/services/v3/views-v3.service.ts+++ b/packages/nocodb/src/services/v3/views-v3.service.ts@@ -18,6 +18,7 @@ import { ViewsService } from '~/services/views.service';import { NcError } from '~/helpers/catchError';import { FiltersV3Service } from '~/services/v3/filters-v3.service';import { SortsV3Service } from '~/services/v3/sorts-v3.service';+import { validatePayload } from '~/helpers';const viewTypeMap = {GRID: ViewTypes.GRID,@@ -394,6 +395,12 @@ export class ViewsV3Service {async create(context: NcContext, param: { req: NcRequest; tableId: string }) {const { req, tableId } = param;const { body } = req;++ validatePayload(+ 'swagger-v3.json#/components/schemas/ViewCreate',+ body,+ true,+ );const requestBody = this.v3Tov2ViewBuilders.view().build(body);requestBody.type =diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.tsindex e0b1edee66..d2c34a62d8 100644--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts@@ -78,7 +78,7 @@ export default function () {});describe('view create', () => {- it.only(`will create grid view`, async () => {+ it(`will create grid view`, async () => {const response = await request(context.app).post(`${API_PREFIX}/tables/${table.id}/views`).set('xc-token', context.xc_token)@@ -95,6 +95,30 @@ export default function () {});expect(response.body.type).to.eq('GRID');});+ it(`will create kanban view`, async () => {+ const response = await request(context.app)+ .post(`${API_PREFIX}/tables/${table.id}/views`)+ .set('xc-token', context.xc_token)+ .send({+ name: 'MyView',+ type: 'KANBAN',+ options: {+ stackBy: {+ fieldId: (+ await table.getColumns(ctx)+ ).find((col) => col.title === 'SingleSelect').id,+ },+ },+ sorts: [+ {+ field_id: (+ await table.getColumns(ctx)+ ).find((col) => col.title === 'Title').id,+ },+ ],+ });+ expect(response.body.type).to.eq('KANBAN');+ });});});}