Browse Source

test: UT fix as per new behaviour

pull/5816/head
Raju Udava 2 years ago
parent
commit
30a2adc2a0
  1. 15
      packages/nocodb/tests/unit/rest/tests/tableRow.test.ts
  2. 148
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

15
packages/nocodb/tests/unit/rest/tests/tableRow.test.ts

@ -1422,22 +1422,15 @@ function tableTest() {
rowId: row['Id'], rowId: row['Id'],
}); });
const response = await request(context.app) await request(context.app)
.delete(`/api/v1/db/data/noco/${project.id}/${table.id}/${row['Id']}`) .delete(`/api/v1/db/data/noco/${project.id}/${table.id}/${row['Id']}`)
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
const deleteRow = await getRow(context, { project, table, id: row['Id'] }); const deleteRow = await getRow(context, { project, table, id: row['Id'] });
if (!deleteRow) { if (deleteRow && Object.keys(deleteRow).length > 0) {
throw new Error('Should not delete'); console.log(deleteRow);
} throw new Error('Wrong delete');
if (
!(response.body.message[0] as string).includes(
'is a LinkToAnotherRecord of',
)
) {
throw new Error('Should give ltar foreign key error');
} }
}); });

148
packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

@ -1,12 +1,11 @@
import 'mocha'; import 'mocha';
import { isString } from 'util';
import request from 'supertest';
import { UITypes, ViewTypes } from 'nocodb-sdk';
import { expect } from 'chai';
import init from '../../init'; import init from '../../init';
import { createProject, createSakilaProject } from '../../factory/project'; import { createProject, createSakilaProject } from '../../factory/project';
import request from 'supertest';
import Project from '../../../../src/models/Project';
import Model from '../../../../src/models/Model';
import { createTable, getTable } from '../../factory/table'; import { createTable, getTable } from '../../factory/table';
import View from '../../../../src/models/View';
import { ColumnType, UITypes, ViewTypes } from 'nocodb-sdk';
import { createView } from '../../factory/view'; import { createView } from '../../factory/view';
import { import {
createColumn, createColumn,
@ -21,9 +20,11 @@ import {
getOneRow, getOneRow,
getRow, getRow,
} from '../../factory/row'; } from '../../factory/row';
import { expect } from 'chai';
import { isPg } from '../../init/db'; import { isPg } from '../../init/db';
import { isString } from 'util'; import type { ColumnType } from 'nocodb-sdk';
import type View from '../../../../src/models/View';
import type Model from '../../../../src/models/Model';
import type Project from '../../../../src/models/Project';
// Test case list // Test case list
// 1. Get view row list g // 1. Get view row list g
@ -160,7 +161,7 @@ function viewRowTests() {
const testGetViewRowList = async (view: View) => { const testGetViewRowList = async (view: View) => {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -179,7 +180,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -225,7 +226,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -244,7 +245,7 @@ function viewRowTests() {
requiredColumns.map((c: ColumnType) => ({ requiredColumns.map((c: ColumnType) => ({
title: c.title, title: c.title,
uidt: c.uidt, uidt: c.uidt,
})) })),
); );
throw new Error('Wrong columns'); throw new Error('Wrong columns');
} }
@ -271,7 +272,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -287,7 +288,7 @@ function viewRowTests() {
expect( expect(
Object.keys(response.body.find((e) => e.key === 'NC-17').value.list[0]) Object.keys(response.body.find((e) => e.key === 'NC-17').value.list[0])
.sort() .sort()
.join(',') .join(','),
).to.equal('FilmId,Title'); ).to.equal('FilmId,Title');
}; };
@ -297,14 +298,14 @@ function viewRowTests() {
const testDescSortedViewDataList = async (view: View) => { const testDescSortedViewDataList = async (view: View) => {
const firstNameColumn = customerColumns.find( const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName' (col) => col.title === 'FirstName',
); );
const visibleColumns = [firstNameColumn]; const visibleColumns = [firstNameColumn];
const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'desc' }]; const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'desc' }];
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -332,7 +333,7 @@ function viewRowTests() {
Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize; Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize;
const lastPageResponse = await request(context.app) const lastPageResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -375,7 +376,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -390,7 +391,7 @@ function viewRowTests() {
expect(response.body).to.be.have.length(6); expect(response.body).to.be.have.length(6);
expect( expect(
response.body.find((e) => e.key === 'PG').value.list[0].Title response.body.find((e) => e.key === 'PG').value.list[0].Title,
).to.equal('WORST BANGER'); ).to.equal('WORST BANGER');
}; };
@ -400,14 +401,14 @@ function viewRowTests() {
const testAscSortedViewDataList = async (view: View) => { const testAscSortedViewDataList = async (view: View) => {
const firstNameColumn = customerColumns.find( const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName' (col) => col.title === 'FirstName',
); );
const visibleColumns = [firstNameColumn]; const visibleColumns = [firstNameColumn];
const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'asc' }]; const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'asc' }];
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -435,7 +436,7 @@ function viewRowTests() {
Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize; Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize;
const lastPageResponse = await request(context.app) const lastPageResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -478,7 +479,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -493,7 +494,7 @@ function viewRowTests() {
expect(response.body).to.be.have.length(6); expect(response.body).to.be.have.length(6);
expect( expect(
response.body.find((e) => e.key === 'PG').value.list[0].Title response.body.find((e) => e.key === 'PG').value.list[0].Title,
).to.equal('ACADEMY DINOSAUR'); ).to.equal('ACADEMY DINOSAUR');
}; };
@ -502,7 +503,7 @@ function viewRowTests() {
}); });
const testGetViewDataListWithRequiredColumnsAndFilter = async ( const testGetViewDataListWithRequiredColumnsAndFilter = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const rentalTable = await getTable({ const rentalTable = await getTable({
project: sakilaProject, project: sakilaProject,
@ -523,7 +524,7 @@ function viewRowTests() {
}); });
const paymentListColumn = (await rentalTable.getColumns()).find( const paymentListColumn = (await rentalTable.getColumns()).find(
(c) => c.title === 'Payment List' (c) => c.title === 'Payment List',
); );
const nestedFilter = { const nestedFilter = {
@ -549,7 +550,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -560,7 +561,7 @@ function viewRowTests() {
const ascResponse = await request(context.app) const ascResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -579,7 +580,7 @@ function viewRowTests() {
const descResponse = await request(context.app) const descResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -606,7 +607,7 @@ function viewRowTests() {
}); });
const testGetNestedSortedFilteredTableDataListWithLookupColumn = async ( const testGetNestedSortedFilteredTableDataListWithLookupColumn = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const view = await createView(context, { const view = await createView(context, {
title: 'View', title: 'View',
@ -624,11 +625,11 @@ function viewRowTests() {
}); });
const paymentListColumn = (await customerTable.getColumns()).find( const paymentListColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Payment List' (c) => c.title === 'Payment List',
); );
const activeColumn = (await customerTable.getColumns()).find( const activeColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Active' (c) => c.title === 'Active',
); );
const nestedFields = { const nestedFields = {
@ -681,7 +682,7 @@ function viewRowTests() {
const ascResponse = await request(context.app) const ascResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -703,7 +704,7 @@ function viewRowTests() {
} }
const nestedRentalResponse = Object.keys( const nestedRentalResponse = Object.keys(
ascResponse.body.list[0]['Rental List'][0] ascResponse.body.list[0]['Rental List'][0],
); );
if ( if (
@ -719,7 +720,7 @@ function viewRowTests() {
it('Get nested sorted filtered table with nested fields data list with a rollup column in customer table view grid', async () => { it('Get nested sorted filtered table with nested fields data list with a rollup column in customer table view grid', async () => {
await testGetNestedSortedFilteredTableDataListWithLookupColumn( await testGetNestedSortedFilteredTableDataListWithLookupColumn(
ViewTypes.GRID ViewTypes.GRID,
); );
}); });
@ -774,7 +775,7 @@ function viewRowTests() {
await request(context.app) await request(context.app)
.post( .post(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
@ -802,7 +803,7 @@ function viewRowTests() {
// todo: Test that all the columns needed to be shown in the view are returned // todo: Test that all the columns needed to be shown in the view are returned
const testFindOneSortedDataWithRequiredColumns = async ( const testFindOneSortedDataWithRequiredColumns = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const view = await createView(context, { const view = await createView(context, {
title: 'View', title: 'View',
@ -810,13 +811,13 @@ function viewRowTests() {
type: viewType, type: viewType,
}); });
const firstNameColumn = customerColumns.find( const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName' (col) => col.title === 'FirstName',
); );
const visibleColumns = [firstNameColumn]; const visibleColumns = [firstNameColumn];
let response = await request(context.app) let response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -837,7 +838,7 @@ function viewRowTests() {
response = await request(context.app) response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -870,7 +871,7 @@ function viewRowTests() {
}); });
const testFindOneSortedFilteredNestedFieldsDataWithRollup = async ( const testFindOneSortedFilteredNestedFieldsDataWithRollup = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const rollupColumn = await createRollupColumn(context, { const rollupColumn = await createRollupColumn(context, {
project: sakilaProject, project: sakilaProject,
@ -893,11 +894,11 @@ function viewRowTests() {
}); });
const paymentListColumn = (await customerTable.getColumns()).find( const paymentListColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Payment List' (c) => c.title === 'Payment List',
); );
const activeColumn = (await customerTable.getColumns()).find( const activeColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Active' (c) => c.title === 'Active',
); );
const nestedFields = { const nestedFields = {
@ -950,7 +951,7 @@ function viewRowTests() {
const ascResponse = await request(context.app) const ascResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -995,7 +996,7 @@ function viewRowTests() {
type: viewType, type: viewType,
}); });
const firstNameColumn = customerColumns.find( const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName' (col) => col.title === 'FirstName',
); );
const rollupColumn = await createRollupColumn(context, { const rollupColumn = await createRollupColumn(context, {
@ -1012,7 +1013,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -1049,7 +1050,7 @@ function viewRowTests() {
}); });
const firstNameColumn = customerColumns.find( const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName' (col) => col.title === 'FirstName',
); );
const rollupColumn = await createRollupColumn(context, { const rollupColumn = await createRollupColumn(context, {
@ -1066,7 +1067,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
@ -1105,7 +1106,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1136,7 +1137,7 @@ function viewRowTests() {
const listResponse = await request(context.app) const listResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1145,7 +1146,7 @@ function viewRowTests() {
const readResponse = await request(context.app) const readResponse = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1181,7 +1182,7 @@ function viewRowTests() {
const updateResponse = await request(context.app) const updateResponse = await request(context.app)
.patch( .patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
@ -1207,7 +1208,7 @@ function viewRowTests() {
}); });
const testUpdateViewRowWithValidationAndInvalidData = async ( const testUpdateViewRowWithValidationAndInvalidData = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const table = await createTable(context, project); const table = await createTable(context, project);
const emailColumn = await createColumn(context, table, { const emailColumn = await createColumn(context, table, {
@ -1228,7 +1229,7 @@ function viewRowTests() {
await request(context.app) await request(context.app)
.patch( .patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
@ -1253,7 +1254,7 @@ function viewRowTests() {
// todo: Test with form view // todo: Test with form view
const testUpdateViewRowWithValidationAndValidData = async ( const testUpdateViewRowWithValidationAndValidData = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const table = await createTable(context, project); const table = await createTable(context, project);
const emailColumn = await createColumn(context, table, { const emailColumn = await createColumn(context, table, {
@ -1273,7 +1274,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.patch( .patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.send({ .send({
@ -1314,7 +1315,7 @@ function viewRowTests() {
await request(context.app) await request(context.app)
.delete( .delete(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1338,8 +1339,8 @@ function viewRowTests() {
await testDeleteViewRow(ViewTypes.FORM); await testDeleteViewRow(ViewTypes.FORM);
}); });
const testDeleteViewRowWithForiegnKeyConstraint = async ( const testDeleteViewRowWithForeignKeyConstraint = async (
viewType: ViewTypes viewType: ViewTypes,
) => { ) => {
const table = await createTable(context, project); const table = await createTable(context, project);
const relatedTable = await createTable(context, project, { const relatedTable = await createTable(context, project, {
@ -1369,37 +1370,30 @@ function viewRowTests() {
rowId: row['Id'], rowId: row['Id'],
}); });
const response = await request(context.app) await request(context.app)
.delete( .delete(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}` `/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
const deleteRow = await getRow(context, { project, table, id: row['Id'] }); const deleteRow = await getRow(context, { project, table, id: row['Id'] });
if (!deleteRow) { if (deleteRow && Object.keys(deleteRow).length > 0) {
throw new Error('Should not delete'); console.log(deleteRow);
} throw new Error('Wrong delete');
if (
!(response.body.message[0] as string).includes(
'is a LinkToAnotherRecord of'
)
) {
throw new Error('Should give ltar foreign key error');
} }
}; };
it('Delete view row with ltar foreign key constraint GALLERY', async function () { it('Delete view row with ltar foreign key constraint GALLERY', async function () {
await testDeleteViewRowWithForiegnKeyConstraint(ViewTypes.GALLERY); await testDeleteViewRowWithForeignKeyConstraint(ViewTypes.GALLERY);
}); });
it('Delete view row with ltar foreign key constraint GRID', async function () { it('Delete view row with ltar foreign key constraint GRID', async function () {
await testDeleteViewRowWithForiegnKeyConstraint(ViewTypes.GRID); await testDeleteViewRowWithForeignKeyConstraint(ViewTypes.GRID);
}); });
it('Delete view row with ltar foreign key constraint FORM', async function () { it('Delete view row with ltar foreign key constraint FORM', async function () {
await testDeleteViewRowWithForiegnKeyConstraint(ViewTypes.FORM); await testDeleteViewRowWithForeignKeyConstraint(ViewTypes.FORM);
}); });
const testViewRowExists = async (viewType: ViewTypes) => { const testViewRowExists = async (viewType: ViewTypes) => {
@ -1415,7 +1409,7 @@ function viewRowTests() {
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}/exist` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}/exist`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1445,7 +1439,7 @@ function viewRowTests() {
}); });
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/999999/exist` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/999999/exist`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1475,7 +1469,7 @@ function viewRowTests() {
}); });
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/csv` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/csv`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);
@ -1499,7 +1493,7 @@ function viewRowTests() {
}); });
const response = await request(context.app) const response = await request(context.app)
.get( .get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/excel` `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/excel`,
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.expect(200); .expect(200);

Loading…
Cancel
Save