Browse Source

test: ut fix for ltar column name change

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5848/head
Raju Udava 2 years ago
parent
commit
2c1b92bf48
  1. 56
      packages/nocodb/tests/unit/rest/tests/tableRow.test.ts
  2. 10
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

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

@ -611,7 +611,7 @@ function tableTest() {
}); });
const paymentListColumn = (await customerTable.getColumns()).find( const paymentListColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Payment List', (c) => c.title === 'Payments',
); );
const activeColumn = (await customerTable.getColumns()).find( const activeColumn = (await customerTable.getColumns()).find(
@ -771,7 +771,7 @@ function tableTest() {
); );
const nestedFields = { const nestedFields = {
'Rental List': { fields: ['RentalDate', 'ReturnDate'] }, Rentals: { fields: ['RentalDate', 'ReturnDate'] },
}; };
const nestedFilter = [ const nestedFilter = [
@ -837,7 +837,7 @@ function tableTest() {
} }
const nestedRentalResponse = Object.keys( const nestedRentalResponse = Object.keys(
ascResponse.body.list[0]['Rental List'], ascResponse.body.list[0]['Rentals'],
); );
if ( if (
nestedRentalResponse.includes('ReturnDate') && nestedRentalResponse.includes('ReturnDate') &&
@ -1072,7 +1072,7 @@ function tableTest() {
); );
const nestedFields = { const nestedFields = {
'Rental List': { Rentals: {
f: 'RentalDate,ReturnDate', f: 'RentalDate,ReturnDate',
}, },
}; };
@ -1132,7 +1132,7 @@ function tableTest() {
throw new Error('Wrong filter'); throw new Error('Wrong filter');
} }
const nestedRentalResponse = Object.keys(ascResponse.body['Rental List']); const nestedRentalResponse = Object.keys(ascResponse.body['Rentals']);
if ( if (
nestedRentalResponse.includes('RentalId') && nestedRentalResponse.includes('RentalId') &&
nestedRentalResponse.includes('RentalDate') && nestedRentalResponse.includes('RentalDate') &&
@ -1250,15 +1250,15 @@ function tableTest() {
) )
.set('xc-auth', context.token) .set('xc-auth', context.token)
.query({ .query({
'nested[Film List][fields]': 'Title,ReleaseYear,Language', 'nested[Films][fields]': 'Title,ReleaseYear,Language',
}) })
.expect(200); .expect(200);
const record = response.body; const record = response.body;
if (isPg(context)) { if (isPg(context)) {
expect(record['Film List']).to.equal('19'); expect(record['Films']).to.equal('19');
} else { } else {
expect(record['Film List']).to.equal(19); expect(record['Films']).to.equal(19);
} }
}); });
@ -1634,7 +1634,7 @@ function tableTest() {
it('Nested row list hm', async () => { it('Nested row list hm', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1653,7 +1653,7 @@ function tableTest() {
it('Nested row list hm with limit and offset', async () => { it('Nested row list hm with limit and offset', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1679,7 +1679,7 @@ function tableTest() {
it('Row list hm with invalid table id', async () => { it('Row list hm with invalid table id', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1703,7 +1703,7 @@ function tableTest() {
// const visibleColumns = [firstNameColumn]; // const visibleColumns = [firstNameColumn];
// const rentalListColumn = (await customerTable.getColumns()).find( // const rentalListColumn = (await customerTable.getColumns()).find(
// (column) => column.title === 'Rental List' // (column) => column.title === 'Rentals'
// )!; // )!;
// const response = await request(context.app) // const response = await request(context.app)
// .get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/${rowId}/hm/${rentalListColumn.id}`) // .get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/${rowId}/hm/${rentalListColumn.id}`)
@ -1731,7 +1731,7 @@ function tableTest() {
}); });
const filmTable = await getTable({ project: sakilaProject, name: 'film' }); const filmTable = await getTable({ project: sakilaProject, name: 'film' });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1755,7 +1755,7 @@ function tableTest() {
}); });
const filmTable = await getTable({ project: sakilaProject, name: 'film' }); const filmTable = await getTable({ project: sakilaProject, name: 'film' });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1786,7 +1786,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.get( .get(
@ -1804,7 +1804,7 @@ function tableTest() {
it('Create hm relation with invalid table id', async () => { it('Create hm relation with invalid table id', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const refId = 1; const refId = 1;
const response = await request(context.app) const response = await request(context.app)
@ -1861,7 +1861,7 @@ function tableTest() {
// it.only('Create list mm existing ref row id', async () => { // it.only('Create list mm existing ref row id', async () => {
// const rowId = 1; // const rowId = 1;
// const rentalListColumn = (await customerTable.getColumns()).find( // const rentalListColumn = (await customerTable.getColumns()).find(
// (column) => column.title === 'Rental List' // (column) => column.title === 'Rentals'
// )!; // )!;
// const refId = 1; // const refId = 1;
@ -1879,7 +1879,7 @@ function tableTest() {
it('Create list hm', async () => { it('Create list hm', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const refId = 1; const refId = 1;
@ -1966,7 +1966,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const refId = 1; const refId = 1;
@ -1988,7 +1988,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const refId = 2; const refId = 2;
@ -2057,7 +2057,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const refId = 1; const refId = 1;
@ -2097,7 +2097,7 @@ function tableTest() {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const refId = 76; const refId = 76;
@ -2173,7 +2173,7 @@ function tableTest() {
it('Exclude list hm', async () => { it('Exclude list hm', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
@ -2192,7 +2192,7 @@ function tableTest() {
it('Exclude list hm with limit and offset', async () => { it('Exclude list hm with limit and offset', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
@ -2224,7 +2224,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
@ -2247,7 +2247,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
@ -2321,7 +2321,7 @@ function tableTest() {
it('Create nested hm relation with invalid table id', async () => { it('Create nested hm relation with invalid table id', async () => {
const rowId = 1; const rowId = 1;
const rentalListColumn = (await customerTable.getColumns()).find( const rentalListColumn = (await customerTable.getColumns()).find(
(column) => column.title === 'Rental List', (column) => column.title === 'Rentals',
)!; )!;
const refId = 1; const refId = 1;
const response = await request(context.app) const response = await request(context.app)
@ -2344,7 +2344,7 @@ function tableTest() {
name: 'actor', name: 'actor',
}); });
const filmListColumn = (await actorTable.getColumns()).find( const filmListColumn = (await actorTable.getColumns()).find(
(column) => column.title === 'Film List', (column) => column.title === 'Films',
)!; )!;
const response = await request(context.app) const response = await request(context.app)
.post( .post(

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

@ -618,7 +618,7 @@ function viewRowTests() {
); );
const nestedFields = { const nestedFields = {
'Rental List': { fields: ['RentalDate', 'ReturnDate'] }, Rentals: { fields: ['RentalDate', 'ReturnDate'] },
}; };
const nestedFilter = [ const nestedFilter = [
@ -683,9 +683,9 @@ function viewRowTests() {
} }
if (isPg(context)) { if (isPg(context)) {
expect(ascResponse.body.list[0]['Rental List']).to.equal('12'); expect(ascResponse.body.list[0]['Rentals']).to.equal('12');
} else { } else {
expect(ascResponse.body.list[0]['Rental List']).to.equal(12); expect(ascResponse.body.list[0]['Rentals']).to.equal(12);
} }
}; };
@ -869,7 +869,7 @@ function viewRowTests() {
); );
const nestedFields = { const nestedFields = {
'Rental List': { f: 'RentalDate,ReturnDate' }, Rentals: { f: 'RentalDate,ReturnDate' },
}; };
const nestedFilter = [ const nestedFilter = [
@ -927,7 +927,7 @@ function viewRowTests() {
throw new Error('Wrong filter'); throw new Error('Wrong filter');
} }
const nestedRentalResponse = Object.keys(ascResponse.body['Rental List']); const nestedRentalResponse = Object.keys(ascResponse.body['Rentals']);
if ( if (
nestedRentalResponse.includes('RentalId') && nestedRentalResponse.includes('RentalId') &&
nestedRentalResponse.includes('RentalDate') && nestedRentalResponse.includes('RentalDate') &&

Loading…
Cancel
Save