Browse Source

test: unit test response

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6307/head
mertmit 1 year ago
parent
commit
304ac9910e
  1. 18
      packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

18
packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

@ -120,6 +120,8 @@ let countryColumns;
let cityTable: Model; let cityTable: Model;
let cityColumns; let cityColumns;
const unauthorizedResponse = process.env.EE !== 'true' ? 404 : 403;
// Optimisation scope for time reduction // Optimisation scope for time reduction
// 1. BeforeEach can be changed to BeforeAll for List and Read APIs // 1. BeforeEach can be changed to BeforeAll for List and Read APIs
@ -795,7 +797,7 @@ function textBased() {
// Invalid table ID // Invalid table ID
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/123456789/rows`, url: `/api/v1/tables/123456789/rows`,
status: 403, status: unauthorizedResponse,
}); });
// Invalid view ID // Invalid view ID
@ -922,7 +924,7 @@ function textBased() {
// Invalid table ID // Invalid table ID
await ncAxiosPost({ await ncAxiosPost({
url: `/api/v1/tables/123456789/rows`, url: `/api/v1/tables/123456789/rows`,
status: 403, status: unauthorizedResponse,
}); });
// Invalid data - create should not specify ID // Invalid data - create should not specify ID
@ -956,7 +958,7 @@ function textBased() {
// Invalid table ID // Invalid table ID
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/123456789/rows/100`, url: `/api/v1/tables/123456789/rows/100`,
status: 403, status: unauthorizedResponse,
}); });
// Invalid row ID // Invalid row ID
await ncAxiosGet({ await ncAxiosGet({
@ -1035,7 +1037,7 @@ function textBased() {
await ncAxiosPatch({ await ncAxiosPatch({
url: `/api/v1/tables/123456789/rows`, url: `/api/v1/tables/123456789/rows`,
body: { Id: 100, SingleLineText: 'some text' }, body: { Id: 100, SingleLineText: 'some text' },
status: 403, status: unauthorizedResponse,
}); });
// Invalid row ID // Invalid row ID
await ncAxiosPatch({ await ncAxiosPatch({
@ -1084,7 +1086,7 @@ function textBased() {
await ncAxiosDelete({ await ncAxiosDelete({
url: `/api/v1/tables/123456789/rows`, url: `/api/v1/tables/123456789/rows`,
body: { Id: 100 }, body: { Id: 100 },
status: 403, status: unauthorizedResponse,
}); });
// Invalid row ID // Invalid row ID
await ncAxiosDelete({ body: { Id: '123456789' }, status: 422 }); await ncAxiosDelete({ body: { Id: '123456789' }, status: 422 });
@ -2377,7 +2379,7 @@ function linkBased() {
await ncAxiosLinkAdd({ await ncAxiosLinkAdd({
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 403, status: unauthorizedResponse,
}); });
// Link Add: Invalid link ID // Link Add: Invalid link ID
@ -2449,7 +2451,7 @@ function linkBased() {
await ncAxiosLinkRemove({ await ncAxiosLinkRemove({
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 403, status: unauthorizedResponse,
}); });
// Link Remove: Invalid link ID // Link Remove: Invalid link ID
@ -2521,7 +2523,7 @@ function linkBased() {
await ncAxiosLinkGet({ await ncAxiosLinkGet({
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 403, status: unauthorizedResponse,
}); });
// Link List: Invalid link ID // Link List: Invalid link ID

Loading…
Cancel
Save