π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
add delete all test
Fendy Heryanto1e7b9b9aaf24
diff --git a/packages/nocodb/tests/unit/rest/index.test.ts b/packages/nocodb/tests/unit/rest/index.test.tsindex f0bca67fde..abf88ca0ca 100644--- a/packages/nocodb/tests/unit/rest/index.test.ts+++ b/packages/nocodb/tests/unit/rest/index.test.ts@@ -14,6 +14,7 @@ import readOnlyTest from './tests/readOnlySource.test';import aggregationTest from './tests/aggregation.test';import dataAPIsV3Test from './tests/dataAPIsV3.test';+import bulkV1Test from './tests/bulk-v1.test';import metaTestV3 from './tests/metaApiV3/index.test';import tableTests from './tests/meta-apis/table.test';import { paymentTest } from './tests/payment/payment.test';@@ -56,6 +57,7 @@ function restTests() {columnTest();integrationTest();paymentTest();+ bulkV1Test();if (testVersion.includes('v1')) tableTests('v1');if (testVersion.includes('v2')) dataAPIsV3Test('v2');diff --git a/packages/nocodb/tests/unit/rest/tests/bulk-v1.test.ts b/packages/nocodb/tests/unit/rest/tests/bulk-v1.test.tsnew file mode 100644index 0000000000..04a3f42edb--- /dev/null+++ b/packages/nocodb/tests/unit/rest/tests/bulk-v1.test.ts@@ -0,0 +1,73 @@+import 'mocha';+import { UITypes } from 'nocodb-sdk';+import { expect } from 'chai';+import init from '../../init';+import { createProject } from '../../factory/base';+import { createTable } from '../../factory/table';+import { createBulkRows, listRow, rowMixedValue } from '../../factory/row';+import { updateColumn } from '../../factory/column';+import {+ beforeEachAttachment,+ beforeEachCheckbox,+ beforeEachLinkBased,+ beforeEachTextBased,+ beforeEachUserBased,+ beforeEach as dataApiV3BeforeEach,+} from './dataApiV3/beforeEach';+import { type INcAxios, ncAxios } from './dataApiV3/ncAxios';+import type { Column } from '../../../../src/models';+import type Model from '../../../../src/models/Model';+import type Base from '~/models/Base';+import type { ITestContext } from './dataApiV3/helpers';++function bulkV1Tests() {+ describe('delete all', () => {+ let testContext: ITestContext;+ let testAxios: INcAxios;+ let ncAxiosGet: INcAxios['ncAxiosGet'];+ let ncAxiosPost: INcAxios['ncAxiosPost'];+ let ncAxiosPatch: INcAxios['ncAxiosPatch'];+ let ncAxiosDelete: INcAxios['ncAxiosDelete'];+ let ncAxiosLinkGet: INcAxios['ncAxiosLinkGet'];+ let ncAxiosLinkAdd: INcAxios['ncAxiosLinkAdd'];+ let ncAxiosLinkRemove: INcAxios['ncAxiosLinkRemove'];+ let table: Model;+ let columns: Column[];+ let insertedRecords: any[];++ beforeEach(async () => {+ testContext = await dataApiV3BeforeEach();+ testAxios = ncAxios(testContext);++ ncAxiosGet = testAxios.ncAxiosGet;+ ncAxiosPost = testAxios.ncAxiosPost;+ ncAxiosPatch = testAxios.ncAxiosPatch;+ ncAxiosDelete = testAxios.ncAxiosDelete;+ ncAxiosLinkGet = testAxios.ncAxiosLinkGet;+ ncAxiosLinkAdd = testAxios.ncAxiosLinkAdd;+ ncAxiosLinkRemove = testAxios.ncAxiosLinkRemove;+ const initResult = await beforeEachTextBased(testContext);+ table = initResult.table;+ columns = initResult.columns;+ insertedRecords = initResult.insertedRecords;+ });+ it(`will delete all and leave no records`, async () => {+ const getRsp1 = await ncAxiosGet({+ url: `/api/v3/data/${testContext.base.id}/${table.id}/records`,+ });+ expect(getRsp1.body.records.length).to.greaterThan(0);+ await ncAxiosDelete({+ url: `/api/v1/db/data/bulk/${testContext.ctx.workspace_id}/${testContext.ctx.base_id}/${table.id}/all`,+ });++ const getRsp2 = await ncAxiosGet({+ url: `/api/v3/data/${testContext.base.id}/${table.id}/records`,+ });+ expect(getRsp2.body.records.length).to.eq(0);+ });+ });+}++export default function () {+ describe('Bulk V1', bulkV1Tests);+}