Browse Source

fix(nc-gui): Renamed data table api to v2

pull/6624/head
Muhammed Mustafa 12 months ago
parent
commit
984f1d167b
  1. 56
      packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

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

@ -139,7 +139,7 @@ const verifyColumnsInRsp = (row, columns: ColumnType[]) => {
}; };
async function ncAxiosGet({ async function ncAxiosGet({
url = `/api/v1/tables/${table.id}/records`, url = `/api/v2/tables/${table.id}/records`,
query = {}, query = {},
status = 200, status = 200,
}: { url?: string; query?: any; status?: number } = {}) { }: { url?: string; query?: any; status?: number } = {}) {
@ -153,7 +153,7 @@ async function ncAxiosGet({
} }
async function ncAxiosPost({ async function ncAxiosPost({
url = `/api/v1/tables/${table.id}/records`, url = `/api/v2/tables/${table.id}/records`,
body = {}, body = {},
status = 200, status = 200,
}: { url?: string; body?: any; status?: number } = {}) { }: { url?: string; body?: any; status?: number } = {}) {
@ -166,7 +166,7 @@ async function ncAxiosPost({
} }
async function ncAxiosPatch({ async function ncAxiosPatch({
url = `/api/v1/tables/${table.id}/records`, url = `/api/v2/tables/${table.id}/records`,
body = {}, body = {},
status = 200, status = 200,
}: { url?: string; body?: any; status?: number } = {}) { }: { url?: string; body?: any; status?: number } = {}) {
@ -179,7 +179,7 @@ async function ncAxiosPatch({
} }
async function ncAxiosDelete({ async function ncAxiosDelete({
url = `/api/v1/tables/${table.id}/records`, url = `/api/v2/tables/${table.id}/records`,
body = {}, body = {},
status = 200, status = 200,
}: { url?: string; body?: any; status?: number } = {}) { }: { url?: string; body?: any; status?: number } = {}) {
@ -200,7 +200,7 @@ async function ncAxiosLinkGet({
msg, msg,
}: { urlParams?: any; query?: any; status?: number; msg?: string } = {}) { }: { urlParams?: any; query?: any; status?: number; msg?: string } = {}) {
const urlParams = { tableId, linkId, rowId }; const urlParams = { tableId, linkId, rowId };
const url = `/api/v1/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`; const url = `/api/v2/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`;
const response = await request(context.app) const response = await request(context.app)
.get(url) .get(url)
.set('xc-auth', context.token) .set('xc-auth', context.token)
@ -226,7 +226,7 @@ async function ncAxiosLinkAdd({
msg, msg,
}: { urlParams?: any; body?: any; status?: number; msg?: string } = {}) { }: { urlParams?: any; body?: any; status?: number; msg?: string } = {}) {
const urlParams = { tableId, linkId, rowId }; const urlParams = { tableId, linkId, rowId };
const url = `/api/v1/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`; const url = `/api/v2/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`;
const response = await request(context.app) const response = await request(context.app)
.post(url) .post(url)
.set('xc-auth', context.token) .set('xc-auth', context.token)
@ -253,7 +253,7 @@ async function ncAxiosLinkRemove({
msg, msg,
}: { urlParams?: any; body?: any; status?: number; msg?: string } = {}) { }: { urlParams?: any; body?: any; status?: number; msg?: string } = {}) {
const urlParams = { tableId, linkId, rowId }; const urlParams = { tableId, linkId, rowId };
const url = `/api/v1/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`; const url = `/api/v2/tables/${urlParams.tableId}/links/${urlParams.linkId}/records/${urlParams.rowId}`;
const response = await request(context.app) const response = await request(context.app)
.delete(url) .delete(url)
.set('xc-auth', context.token) .set('xc-auth', context.token)
@ -310,7 +310,7 @@ function generalDb() {
// read first 4 records // read first 4 records
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records`, url: `/api/v2/tables/${countryTable.id}/records`,
query: { query: {
limit: 4, limit: 4,
}, },
@ -340,7 +340,7 @@ function generalDb() {
// read first 4 records // read first 4 records
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records`, url: `/api/v2/tables/${countryTable.id}/records`,
query: { query: {
limit: 4, limit: 4,
}, },
@ -366,7 +366,7 @@ function generalDb() {
// read first 4 records // read first 4 records
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records`, url: `/api/v2/tables/${countryTable.id}/records`,
query: { query: {
limit: 4, limit: 4,
}, },
@ -381,7 +381,7 @@ function generalDb() {
it('Nested Read - Link to another record', async function () { it('Nested Read - Link to another record', async function () {
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records/1`, url: `/api/v2/tables/${countryTable.id}/records/1`,
}); });
// extract LTAR column "City List" // extract LTAR column "City List"
@ -398,7 +398,7 @@ function generalDb() {
}); });
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records/1`, url: `/api/v2/tables/${countryTable.id}/records/1`,
}); });
expect(records.body.Lookup).to.deep.equal(['Kabul']); expect(records.body.Lookup).to.deep.equal(['Kabul']);
}); });
@ -414,7 +414,7 @@ function generalDb() {
}); });
const records = await ncAxiosGet({ const records = await ncAxiosGet({
url: `/api/v1/tables/${countryTable.id}/records/1`, url: `/api/v2/tables/${countryTable.id}/records/1`,
}); });
expect(records.body.Rollup).to.equal(1); expect(records.body.Rollup).to.equal(1);
@ -792,7 +792,7 @@ function textBased() {
it('List: invalid ID', async function () { it('List: invalid ID', async function () {
// Invalid table ID // Invalid table ID
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/123456789/records`, url: `/api/v2/tables/123456789/records`,
status: unauthorizedResponse, status: unauthorizedResponse,
}); });
@ -919,7 +919,7 @@ function textBased() {
it('Create: invalid ID', async function () { it('Create: invalid ID', async function () {
// Invalid table ID // Invalid table ID
await ncAxiosPost({ await ncAxiosPost({
url: `/api/v1/tables/123456789/records`, url: `/api/v2/tables/123456789/records`,
status: unauthorizedResponse, status: unauthorizedResponse,
}); });
@ -946,19 +946,19 @@ function textBased() {
it('Read: all fields', async function () { it('Read: all fields', async function () {
const rsp = await ncAxiosGet({ const rsp = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/100`, url: `/api/v2/tables/${table.id}/records/100`,
}); });
}); });
it('Read: invalid ID', async function () { it('Read: invalid ID', async function () {
// Invalid table ID // Invalid table ID
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/123456789/records/100`, url: `/api/v2/tables/123456789/records/100`,
status: unauthorizedResponse, status: unauthorizedResponse,
}); });
// Invalid row ID // Invalid row ID
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/1000`, url: `/api/v2/tables/${table.id}/records/1000`,
status: 404, status: 404,
}); });
}); });
@ -984,7 +984,7 @@ function textBased() {
it('Update: partial', async function () { it('Update: partial', async function () {
const recordBeforeUpdate = await ncAxiosGet({ const recordBeforeUpdate = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/1`, url: `/api/v2/tables/${table.id}/records/1`,
}); });
const rsp = await ncAxiosPatch({ const rsp = await ncAxiosPatch({
@ -999,7 +999,7 @@ function textBased() {
expect(rsp.body).to.deep.equal([{ Id: 1 }]); expect(rsp.body).to.deep.equal([{ Id: 1 }]);
const recordAfterUpdate = await ncAxiosGet({ const recordAfterUpdate = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/1`, url: `/api/v2/tables/${table.id}/records/1`,
}); });
expect(recordAfterUpdate.body).to.deep.equal({ expect(recordAfterUpdate.body).to.deep.equal({
...recordBeforeUpdate.body, ...recordBeforeUpdate.body,
@ -1031,7 +1031,7 @@ function textBased() {
it('Update: invalid ID', async function () { it('Update: invalid ID', async function () {
// Invalid table ID // Invalid table ID
await ncAxiosPatch({ await ncAxiosPatch({
url: `/api/v1/tables/123456789/records`, url: `/api/v2/tables/123456789/records`,
body: { Id: 100, SingleLineText: 'some text' }, body: { Id: 100, SingleLineText: 'some text' },
status: unauthorizedResponse, status: unauthorizedResponse,
}); });
@ -1055,7 +1055,7 @@ function textBased() {
// check that it's gone // check that it's gone
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/1`, url: `/api/v2/tables/${table.id}/records/1`,
status: 404, status: 404,
}); });
}); });
@ -1066,11 +1066,11 @@ function textBased() {
// check that it's gone // check that it's gone
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/1`, url: `/api/v2/tables/${table.id}/records/1`,
status: 404, status: 404,
}); });
await ncAxiosGet({ await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/2`, url: `/api/v2/tables/${table.id}/records/2`,
status: 404, status: 404,
}); });
}); });
@ -1080,7 +1080,7 @@ function textBased() {
it('Delete: invalid ID', async function () { it('Delete: invalid ID', async function () {
// Invalid table ID // Invalid table ID
await ncAxiosDelete({ await ncAxiosDelete({
url: `/api/v1/tables/123456789/records`, url: `/api/v2/tables/123456789/records`,
body: { Id: 100 }, body: { Id: 100 },
status: unauthorizedResponse, status: unauthorizedResponse,
}); });
@ -1261,7 +1261,7 @@ function numberBased() {
// read record with Id 401 // read record with Id 401
rsp = await ncAxiosGet({ rsp = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/401`, url: `/api/v2/tables/${table.id}/records/401`,
}); });
expect(rsp.body).to.deep.equal({ ...records[0], Id: 401 }); expect(rsp.body).to.deep.equal({ ...records[0], Id: 401 });
@ -1452,7 +1452,7 @@ function selectBased() {
// read record with Id 401 // read record with Id 401
rsp = await ncAxiosGet({ rsp = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/401`, url: `/api/v2/tables/${table.id}/records/401`,
}); });
expect(rsp.body).to.deep.equal({ Id: 401, ...records[0] }); expect(rsp.body).to.deep.equal({ Id: 401, ...records[0] });
@ -1591,7 +1591,7 @@ function dateBased() {
// read record with Id 801 // read record with Id 801
rsp = await ncAxiosGet({ rsp = await ncAxiosGet({
url: `/api/v1/tables/${table.id}/records/801`, url: `/api/v2/tables/${table.id}/records/801`,
}); });
expect(rsp.body).to.deep.equal({ Id: 801, ...records[0] }); expect(rsp.body).to.deep.equal({ Id: 801, ...records[0] });

Loading…
Cancel
Save