|
|
@ -8,8 +8,19 @@ import { createTable, getTable } from '../../factory/table'; |
|
|
|
import View from '../../../../src/lib/models/View'; |
|
|
|
import View from '../../../../src/lib/models/View'; |
|
|
|
import { ColumnType, UITypes, ViewTypes } from 'nocodb-sdk'; |
|
|
|
import { ColumnType, UITypes, ViewTypes } from 'nocodb-sdk'; |
|
|
|
import { createView } from '../../factory/view'; |
|
|
|
import { createView } from '../../factory/view'; |
|
|
|
import { createColumn, createLookupColumn, createLtarColumn, createRollupColumn, updateViewColumn } from '../../factory/column'; |
|
|
|
import { |
|
|
|
import { createChildRow, createRow, getOneRow, getRow } from '../../factory/row'; |
|
|
|
createColumn, |
|
|
|
|
|
|
|
createLookupColumn, |
|
|
|
|
|
|
|
createLtarColumn, |
|
|
|
|
|
|
|
createRollupColumn, |
|
|
|
|
|
|
|
updateViewColumn, |
|
|
|
|
|
|
|
} from '../../factory/column'; |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
createChildRow, |
|
|
|
|
|
|
|
createRow, |
|
|
|
|
|
|
|
getOneRow, |
|
|
|
|
|
|
|
getRow, |
|
|
|
|
|
|
|
} from '../../factory/row'; |
|
|
|
import { expect } from 'chai'; |
|
|
|
import { expect } from 'chai'; |
|
|
|
|
|
|
|
|
|
|
|
const isColumnsCorrectInResponse = (row, columns: ColumnType[]) => { |
|
|
|
const isColumnsCorrectInResponse = (row, columns: ColumnType[]) => { |
|
|
@ -36,54 +47,66 @@ function viewRowTests() { |
|
|
|
context = await init(); |
|
|
|
context = await init(); |
|
|
|
sakilaProject = await createSakilaProject(context); |
|
|
|
sakilaProject = await createSakilaProject(context); |
|
|
|
project = await createProject(context); |
|
|
|
project = await createProject(context); |
|
|
|
customerTable = await getTable({project: sakilaProject, name: 'customer'}) |
|
|
|
customerTable = await getTable({ |
|
|
|
|
|
|
|
project: sakilaProject, |
|
|
|
|
|
|
|
name: 'customer', |
|
|
|
|
|
|
|
}); |
|
|
|
customerColumns = await customerTable.getColumns(); |
|
|
|
customerColumns = await customerTable.getColumns(); |
|
|
|
customerGridView = await createView(context, { |
|
|
|
customerGridView = await createView(context, { |
|
|
|
title: 'Customer Gallery', |
|
|
|
title: 'Customer Gallery', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: ViewTypes.GRID |
|
|
|
type: ViewTypes.GRID, |
|
|
|
}); |
|
|
|
}); |
|
|
|
customerGalleryView = await createView(context, { |
|
|
|
customerGalleryView = await createView(context, { |
|
|
|
title: 'Customer Gallery', |
|
|
|
title: 'Customer Gallery', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: ViewTypes.GALLERY |
|
|
|
type: ViewTypes.GALLERY, |
|
|
|
}); |
|
|
|
}); |
|
|
|
customerFormView = await createView(context, { |
|
|
|
customerFormView = await createView(context, { |
|
|
|
title: 'Customer Form',
|
|
|
|
title: 'Customer Form', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: ViewTypes.FORM |
|
|
|
type: ViewTypes.FORM, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testGetViewRowListGallery = async (view: View) => { |
|
|
|
const testGetViewRowListGallery = async (view: View) => { |
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/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); |
|
|
|
|
|
|
|
|
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
if(pageInfo.totalRows !== 599 || response.body.list[0]['CustomerId'] !== 1){ |
|
|
|
if ( |
|
|
|
|
|
|
|
pageInfo.totalRows !== 599 || |
|
|
|
|
|
|
|
response.body.list[0]['CustomerId'] !== 1 |
|
|
|
|
|
|
|
) { |
|
|
|
throw new Error('View row list is not correct'); |
|
|
|
throw new Error('View row list is not correct'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Get view row list gallery', async () => { |
|
|
|
it('Get view row list gallery', async () => { |
|
|
|
await testGetViewRowListGallery(customerGalleryView); |
|
|
|
await testGetViewRowListGallery(customerGalleryView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Get view row list form', async () => { |
|
|
|
it('Get view row list form', async () => { |
|
|
|
await testGetViewRowListGallery(customerFormView); |
|
|
|
await testGetViewRowListGallery(customerFormView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Get view row list grid', async () => { |
|
|
|
it('Get view row list grid', async () => { |
|
|
|
await testGetViewRowListGallery(customerGridView); |
|
|
|
await testGetViewRowListGallery(customerGridView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testGetViewDataListWithRequiredColumns = async (view: View) => { |
|
|
|
const testGetViewDataListWithRequiredColumns = async (view: View) => { |
|
|
|
const requiredColumns = customerColumns.filter((_, index) => index < 3).filter((c: ColumnType) => c.uidt !== UITypes.ForeignKey); |
|
|
|
const requiredColumns = customerColumns |
|
|
|
|
|
|
|
.filter((_, index) => index < 3) |
|
|
|
|
|
|
|
.filter((c: ColumnType) => c.uidt !== UITypes.ForeignKey); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
fields: requiredColumns.map((c) => c.title), |
|
|
|
fields: requiredColumns.map((c) => c.title), |
|
|
@ -96,22 +119,28 @@ function viewRowTests() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!isColumnsCorrectInResponse(response.body.list[0], requiredColumns)) { |
|
|
|
if (!isColumnsCorrectInResponse(response.body.list[0], requiredColumns)) { |
|
|
|
console.log(response.body.list[0], requiredColumns.map((c: ColumnType) => ({title: c.title,uidt: c.uidt}))); |
|
|
|
console.log( |
|
|
|
|
|
|
|
response.body.list[0], |
|
|
|
|
|
|
|
requiredColumns.map((c: ColumnType) => ({ |
|
|
|
|
|
|
|
title: c.title, |
|
|
|
|
|
|
|
uidt: c.uidt, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
); |
|
|
|
throw new Error('Wrong columns'); |
|
|
|
throw new Error('Wrong columns'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Get view data list with required columns gallery', async () => { |
|
|
|
it('Get view data list with required columns gallery', async () => { |
|
|
|
await testGetViewDataListWithRequiredColumns(customerGalleryView); |
|
|
|
await testGetViewDataListWithRequiredColumns(customerGalleryView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Get view data list with required columns form', async () => { |
|
|
|
it('Get view data list with required columns form', async () => { |
|
|
|
await testGetViewDataListWithRequiredColumns(customerFormView); |
|
|
|
await testGetViewDataListWithRequiredColumns(customerFormView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Get view data list with required columns grid', async () => { |
|
|
|
it('Get view data list with required columns grid', async () => { |
|
|
|
await testGetViewDataListWithRequiredColumns(customerGridView); |
|
|
|
await testGetViewDataListWithRequiredColumns(customerGridView); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testDescSortedViewDataList = async (view: View) => { |
|
|
|
const testDescSortedViewDataList = async (view: View) => { |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
@ -121,7 +150,9 @@ function viewRowTests() { |
|
|
|
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(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
@ -147,7 +178,9 @@ function viewRowTests() { |
|
|
|
const lastPageOffset = |
|
|
|
const lastPageOffset = |
|
|
|
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(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
@ -164,7 +197,7 @@ function viewRowTests() { |
|
|
|
console.log(lastPageOffset, lastPageResponse.body.list); |
|
|
|
console.log(lastPageOffset, lastPageResponse.body.list); |
|
|
|
throw new Error('Wrong sort on last page'); |
|
|
|
throw new Error('Wrong sort on last page'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Get desc sorted table data list with required columns gallery', async function () { |
|
|
|
it('Get desc sorted table data list with required columns gallery', async function () { |
|
|
|
await testDescSortedViewDataList(customerGalleryView); |
|
|
|
await testDescSortedViewDataList(customerGalleryView); |
|
|
@ -186,7 +219,9 @@ function viewRowTests() { |
|
|
|
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(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
@ -212,7 +247,9 @@ function viewRowTests() { |
|
|
|
const lastPageOffset = |
|
|
|
const lastPageOffset = |
|
|
|
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(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
|
fields: visibleColumns.map((c) => c.title), |
|
|
@ -229,7 +266,7 @@ function viewRowTests() { |
|
|
|
console.log(lastPageOffset, lastPageResponse.body.list); |
|
|
|
console.log(lastPageOffset, lastPageResponse.body.list); |
|
|
|
throw new Error('Wrong sort on last page'); |
|
|
|
throw new Error('Wrong sort on last page'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Get asc sorted view data list with required columns gallery', async function () { |
|
|
|
it('Get asc sorted view data list with required columns gallery', async function () { |
|
|
|
await testAscSortedViewDataList(customerGalleryView); |
|
|
|
await testAscSortedViewDataList(customerGalleryView); |
|
|
@ -243,12 +280,17 @@ function viewRowTests() { |
|
|
|
await testAscSortedViewDataList(customerGridView); |
|
|
|
await testAscSortedViewDataList(customerGridView); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testGetViewDataListWithRequiredColumnsAndFilter = async (viewType: ViewTypes) => { |
|
|
|
const testGetViewDataListWithRequiredColumnsAndFilter = async ( |
|
|
|
const rentalTable = await getTable({project: sakilaProject, name: 'rental'}); |
|
|
|
viewType: ViewTypes |
|
|
|
|
|
|
|
) => { |
|
|
|
|
|
|
|
const rentalTable = await getTable({ |
|
|
|
|
|
|
|
project: sakilaProject, |
|
|
|
|
|
|
|
name: 'rental', |
|
|
|
|
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: rentalTable, |
|
|
|
table: rentalTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const lookupColumn = await createLookupColumn(context, { |
|
|
|
const lookupColumn = await createLookupColumn(context, { |
|
|
@ -285,16 +327,20 @@ function viewRowTests() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
expect(response.body.pageInfo.totalRows).equal(9558) |
|
|
|
expect(response.body.pageInfo.totalRows).equal(9558); |
|
|
|
|
|
|
|
|
|
|
|
const ascResponse = await request(context.app) |
|
|
|
const ascResponse = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
@ -307,11 +353,13 @@ function viewRowTests() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.expect(200); |
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
expect(ascResponse.body.pageInfo.totalRows).equal(9558) |
|
|
|
expect(ascResponse.body.pageInfo.totalRows).equal(9558); |
|
|
|
expect(ascResponse.body.list[0][lookupColumn.title]).equal('AARON') |
|
|
|
expect(ascResponse.body.list[0][lookupColumn.title]).equal('AARON'); |
|
|
|
|
|
|
|
|
|
|
|
const descResponse = await request(context.app) |
|
|
|
const descResponse = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
@ -324,9 +372,9 @@ function viewRowTests() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.expect(200); |
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
expect(descResponse.body.pageInfo.totalRows).equal(9558) |
|
|
|
expect(descResponse.body.pageInfo.totalRows).equal(9558); |
|
|
|
expect(descResponse.body.list[0][lookupColumn.title]).equal('ZACHARY') |
|
|
|
expect(descResponse.body.list[0][lookupColumn.title]).equal('ZACHARY'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Get nested sorted filtered table data list with a lookup column gallery', async function () { |
|
|
|
it('Get nested sorted filtered table data list with a lookup column gallery', async function () { |
|
|
|
await testGetViewDataListWithRequiredColumnsAndFilter(ViewTypes.GALLERY); |
|
|
|
await testGetViewDataListWithRequiredColumnsAndFilter(ViewTypes.GALLERY); |
|
|
@ -336,11 +384,13 @@ function viewRowTests() { |
|
|
|
await testGetViewDataListWithRequiredColumnsAndFilter(ViewTypes.GRID); |
|
|
|
await testGetViewDataListWithRequiredColumnsAndFilter(ViewTypes.GRID); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testGetNestedSortedFilteredTableDataListWithLookupColumn = async (viewType: ViewTypes) => { |
|
|
|
const testGetNestedSortedFilteredTableDataListWithLookupColumn = async ( |
|
|
|
|
|
|
|
viewType: ViewTypes |
|
|
|
|
|
|
|
) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const rollupColumn = await createRollupColumn(context, { |
|
|
|
const rollupColumn = await createRollupColumn(context, { |
|
|
@ -400,7 +450,7 @@ function viewRowTests() { |
|
|
|
fk_column_id: activeColumn?.id, |
|
|
|
fk_column_id: activeColumn?.id, |
|
|
|
status: 'create', |
|
|
|
status: 'create', |
|
|
|
comparison_op: 'eq', |
|
|
|
comparison_op: 'eq', |
|
|
|
value: 1 |
|
|
|
value: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -409,7 +459,9 @@ function viewRowTests() { |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const ascResponse = await request(context.app) |
|
|
|
const ascResponse = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.query({ |
|
|
|
.query({ |
|
|
|
nested: nestedFields, |
|
|
|
nested: nestedFields, |
|
|
@ -434,17 +486,21 @@ function viewRowTests() { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!(nestedRentalResponse.includes('RentalId') && |
|
|
|
!( |
|
|
|
nestedRentalResponse.includes('RentalDate') && |
|
|
|
nestedRentalResponse.includes('RentalId') && |
|
|
|
nestedRentalResponse.length === 2) |
|
|
|
nestedRentalResponse.includes('RentalDate') && |
|
|
|
|
|
|
|
nestedRentalResponse.length === 2 |
|
|
|
|
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
throw new Error('Wrong nested fields'); |
|
|
|
throw new Error('Wrong nested fields'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
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(ViewTypes.GRID); |
|
|
|
await testGetNestedSortedFilteredTableDataListWithLookupColumn( |
|
|
|
}) |
|
|
|
ViewTypes.GRID |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// todo: gallery view doesnt seem to support rollup
|
|
|
|
// todo: gallery view doesnt seem to support rollup
|
|
|
|
// it('Get nested sorted filtered table with nested fields data list with a rollup column in customer table view gallery', async () => {
|
|
|
|
// it('Get nested sorted filtered table with nested fields data list with a rollup column in customer table view gallery', async () => {
|
|
|
@ -454,9 +510,9 @@ function viewRowTests() { |
|
|
|
const testCreateRowView = async (viewType: ViewTypes) => { |
|
|
|
const testCreateRowView = async (viewType: ViewTypes) => { |
|
|
|
const table = await createTable(context, project); |
|
|
|
const table = await createTable(context, project); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
@ -469,7 +525,7 @@ function viewRowTests() { |
|
|
|
|
|
|
|
|
|
|
|
const row = response.body; |
|
|
|
const row = response.body; |
|
|
|
if (row['Title'] !== 'Test') throw new Error('Wrong row title'); |
|
|
|
if (row['Title'] !== 'Test') throw new Error('Wrong row title'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Create table row grid', async function () { |
|
|
|
it('Create table row grid', async function () { |
|
|
|
await testCreateRowView(ViewTypes.GRID); |
|
|
|
await testCreateRowView(ViewTypes.GRID); |
|
|
@ -486,19 +542,21 @@ function viewRowTests() { |
|
|
|
const testCreateRowViewWithWrongView = async (viewType: ViewTypes) => { |
|
|
|
const testCreateRowViewWithWrongView = async (viewType: ViewTypes) => { |
|
|
|
const table = await createTable(context, project); |
|
|
|
const table = await createTable(context, project); |
|
|
|
const nonRelatedView = await createView(context, { |
|
|
|
const nonRelatedView = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await request(context.app) |
|
|
|
await request(context.app) |
|
|
|
.post(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}`) |
|
|
|
.post( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}` |
|
|
|
|
|
|
|
) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.set('xc-auth', context.token) |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: 'Test', |
|
|
|
title: 'Test', |
|
|
|
}) |
|
|
|
}) |
|
|
|
.expect(400); |
|
|
|
.expect(400); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Create table row grid wrong grid id', async function () { |
|
|
|
it('Create table row grid wrong grid id', async function () { |
|
|
|
await testCreateRowViewWithWrongView(ViewTypes.GRID); |
|
|
|
await testCreateRowViewWithWrongView(ViewTypes.GRID); |
|
|
@ -514,11 +572,13 @@ 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 (viewType: ViewTypes) => { |
|
|
|
const testFindOneSortedDataWithRequiredColumns = async ( |
|
|
|
|
|
|
|
viewType: ViewTypes |
|
|
|
|
|
|
|
) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
(col) => col.title === 'FirstName' |
|
|
|
(col) => col.title === 'FirstName' |
|
|
@ -566,7 +626,7 @@ function viewRowTests() { |
|
|
|
console.log(response.body); |
|
|
|
console.log(response.body); |
|
|
|
throw new Error('Wrong sort'); |
|
|
|
throw new Error('Wrong sort'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Find one sorted data list with required columns gallery', async function () { |
|
|
|
it('Find one sorted data list with required columns gallery', async function () { |
|
|
|
await testFindOneSortedDataWithRequiredColumns(ViewTypes.GALLERY); |
|
|
|
await testFindOneSortedDataWithRequiredColumns(ViewTypes.GALLERY); |
|
|
@ -579,8 +639,10 @@ function viewRowTests() { |
|
|
|
it('Find one sorted data list with required columns grid', async function () { |
|
|
|
it('Find one sorted data list with required columns grid', async function () { |
|
|
|
await testFindOneSortedDataWithRequiredColumns(ViewTypes.GRID); |
|
|
|
await testFindOneSortedDataWithRequiredColumns(ViewTypes.GRID); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testFindOneSortedFilteredNestedFieldsDataWithRollup = async (viewType: ViewTypes) => { |
|
|
|
const testFindOneSortedFilteredNestedFieldsDataWithRollup = async ( |
|
|
|
|
|
|
|
viewType: ViewTypes |
|
|
|
|
|
|
|
) => { |
|
|
|
const rollupColumn = await createRollupColumn(context, { |
|
|
|
const rollupColumn = await createRollupColumn(context, { |
|
|
|
project: sakilaProject, |
|
|
|
project: sakilaProject, |
|
|
|
title: 'Number of rentals', |
|
|
|
title: 'Number of rentals', |
|
|
@ -590,17 +652,17 @@ function viewRowTests() { |
|
|
|
relatedTableColumnTitle: 'RentalDate', |
|
|
|
relatedTableColumnTitle: 'RentalDate', |
|
|
|
}); |
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await updateViewColumn(context, { |
|
|
|
await updateViewColumn(context, { |
|
|
|
column: rollupColumn, |
|
|
|
column: rollupColumn, |
|
|
|
view: view, |
|
|
|
view: view, |
|
|
|
attr: {show: true}, |
|
|
|
attr: { show: true }, |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const paymentListColumn = (await customerTable.getColumns()).find( |
|
|
|
const paymentListColumn = (await customerTable.getColumns()).find( |
|
|
|
(c) => c.title === 'Payment List' |
|
|
|
(c) => c.title === 'Payment List' |
|
|
|
); |
|
|
|
); |
|
|
@ -649,7 +711,7 @@ function viewRowTests() { |
|
|
|
fk_column_id: activeColumn?.id, |
|
|
|
fk_column_id: activeColumn?.id, |
|
|
|
status: 'create', |
|
|
|
status: 'create', |
|
|
|
comparison_op: 'eq', |
|
|
|
comparison_op: 'eq', |
|
|
|
value: 1 |
|
|
|
value: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -670,7 +732,7 @@ function viewRowTests() { |
|
|
|
.expect(200); |
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
if (ascResponse.body[rollupColumn.title] !== 12) { |
|
|
|
if (ascResponse.body[rollupColumn.title] !== 12) { |
|
|
|
console.log('response.body',ascResponse.body); |
|
|
|
console.log('response.body', ascResponse.body); |
|
|
|
throw new Error('Wrong filter'); |
|
|
|
throw new Error('Wrong filter'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -682,7 +744,7 @@ function viewRowTests() { |
|
|
|
) { |
|
|
|
) { |
|
|
|
throw new Error('Wrong nested fields'); |
|
|
|
throw new Error('Wrong nested fields'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// todo: gallery view doesnt seem to support rollup
|
|
|
|
// todo: gallery view doesnt seem to support rollup
|
|
|
|
// it.only('Find one sorted filtered view with nested fields data list with a rollup column in customer table GALLERY', async function () {
|
|
|
|
// it.only('Find one sorted filtered view with nested fields data list with a rollup column in customer table GALLERY', async function () {
|
|
|
@ -699,9 +761,9 @@ function viewRowTests() { |
|
|
|
|
|
|
|
|
|
|
|
const testGroupDescSorted = async (viewType: ViewTypes) => { |
|
|
|
const testGroupDescSorted = async (viewType: ViewTypes) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
(col) => col.title === 'FirstName' |
|
|
|
(col) => col.title === 'FirstName' |
|
|
@ -736,7 +798,7 @@ function viewRowTests() { |
|
|
|
response.body.list[4]['count'] !== 2 |
|
|
|
response.body.list[4]['count'] !== 2 |
|
|
|
) |
|
|
|
) |
|
|
|
throw new Error('Wrong groupby'); |
|
|
|
throw new Error('Wrong groupby'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Groupby desc sorted and with rollup view data list with required columns GRID', async function () { |
|
|
|
it('Groupby desc sorted and with rollup view data list with required columns GRID', async function () { |
|
|
|
await testGroupDescSorted(ViewTypes.GRID); |
|
|
|
await testGroupDescSorted(ViewTypes.GRID); |
|
|
@ -752,9 +814,9 @@ function viewRowTests() { |
|
|
|
|
|
|
|
|
|
|
|
const testGroupWithOffset = async (viewType: ViewTypes) => { |
|
|
|
const testGroupWithOffset = async (viewType: ViewTypes) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
|
const firstNameColumn = customerColumns.find( |
|
|
@ -791,7 +853,7 @@ function viewRowTests() { |
|
|
|
response.body.list[0]['count'] !== 2 |
|
|
|
response.body.list[0]['count'] !== 2 |
|
|
|
) |
|
|
|
) |
|
|
|
throw new Error('Wrong groupby'); |
|
|
|
throw new Error('Wrong groupby'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Groupby desc sorted and with rollup view data list with required columns GALLERY', async function () { |
|
|
|
it('Groupby desc sorted and with rollup view data list with required columns GALLERY', async function () { |
|
|
|
await testGroupWithOffset(ViewTypes.GALLERY); |
|
|
|
await testGroupWithOffset(ViewTypes.GALLERY); |
|
|
@ -807,20 +869,22 @@ function viewRowTests() { |
|
|
|
|
|
|
|
|
|
|
|
const testCount = async (viewType: ViewTypes) => { |
|
|
|
const testCount = async (viewType: ViewTypes) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count`) |
|
|
|
.get( |
|
|
|
.set('xc-auth', context.token) |
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count` |
|
|
|
.expect(200); |
|
|
|
) |
|
|
|
|
|
|
|
.set('xc-auth', context.token) |
|
|
|
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
if(response.body.count !== 599) { |
|
|
|
if (response.body.count !== 599) { |
|
|
|
throw new Error('Wrong count'); |
|
|
|
throw new Error('Wrong count'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Count view data list with required columns GRID', async function () { |
|
|
|
it('Count view data list with required columns GRID', async function () { |
|
|
|
await testCount(ViewTypes.GRID); |
|
|
|
await testCount(ViewTypes.GRID); |
|
|
@ -834,16 +898,17 @@ function viewRowTests() { |
|
|
|
await testCount(ViewTypes.GALLERY); |
|
|
|
await testCount(ViewTypes.GALLERY); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const testReadViewRow = async (viewType: ViewTypes) => { |
|
|
|
const testReadViewRow = async (viewType: ViewTypes) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const listResponse = await request(context.app) |
|
|
|
const listResponse = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/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); |
|
|
|
|
|
|
|
|
|
|
@ -862,31 +927,33 @@ function viewRowTests() { |
|
|
|
) { |
|
|
|
) { |
|
|
|
throw new Error('Wrong read'); |
|
|
|
throw new Error('Wrong read'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Read view row GALLERY', async function () { |
|
|
|
it('Read view row GALLERY', async function () { |
|
|
|
await testReadViewRow(ViewTypes.GALLERY); |
|
|
|
await testReadViewRow(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Read view row FORM', async function () { |
|
|
|
it('Read view row FORM', async function () { |
|
|
|
await testReadViewRow(ViewTypes.FORM); |
|
|
|
await testReadViewRow(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Read view row GRID', async function () { |
|
|
|
it('Read view row GRID', async function () { |
|
|
|
await testReadViewRow(ViewTypes.GRID); |
|
|
|
await testReadViewRow(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testUpdateViewRow = async (viewType: ViewTypes) => { |
|
|
|
const testUpdateViewRow = async (viewType: ViewTypes) => { |
|
|
|
const table = await createTable(context, project); |
|
|
|
const table = await createTable(context, project); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const updateResponse = await request(context.app) |
|
|
|
const updateResponse = await request(context.app) |
|
|
|
.patch(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`) |
|
|
|
.patch( |
|
|
|
|
|
|
|
`/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({ |
|
|
|
title: 'Updated', |
|
|
|
title: 'Updated', |
|
|
@ -896,21 +963,23 @@ function viewRowTests() { |
|
|
|
if (updateResponse.body['Title'] !== 'Updated') { |
|
|
|
if (updateResponse.body['Title'] !== 'Updated') { |
|
|
|
throw new Error('Wrong update'); |
|
|
|
throw new Error('Wrong update'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row GALLERY', async function () { |
|
|
|
it('Update view row GALLERY', async function () { |
|
|
|
await testUpdateViewRow(ViewTypes.GALLERY); |
|
|
|
await testUpdateViewRow(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row GRID', async function () { |
|
|
|
it('Update view row GRID', async function () { |
|
|
|
await testUpdateViewRow(ViewTypes.GRID); |
|
|
|
await testUpdateViewRow(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row FORM', async function () { |
|
|
|
it('Update view row FORM', async function () { |
|
|
|
await testUpdateViewRow(ViewTypes.FORM); |
|
|
|
await testUpdateViewRow(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testUpdateViewRowWithValidationAndInvalidData = async (viewType: ViewTypes) => { |
|
|
|
const testUpdateViewRowWithValidationAndInvalidData = async ( |
|
|
|
|
|
|
|
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, { |
|
|
|
title: 'Email', |
|
|
|
title: 'Email', |
|
|
@ -921,38 +990,42 @@ function viewRowTests() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
|
|
|
|
|
|
|
|
await request(context.app) |
|
|
|
await request(context.app) |
|
|
|
.patch(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`) |
|
|
|
.patch( |
|
|
|
|
|
|
|
`/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({ |
|
|
|
[emailColumn.column_name]: 'invalidemail', |
|
|
|
[emailColumn.column_name]: 'invalidemail', |
|
|
|
}) |
|
|
|
}) |
|
|
|
.expect(400); |
|
|
|
.expect(400); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and invalid data GALLERY', async function () { |
|
|
|
it('Update view row with validation and invalid data GALLERY', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.GALLERY); |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and invalid data GRID', async function () { |
|
|
|
it('Update view row with validation and invalid data GRID', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.GRID); |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and invalid data FORM', async function () { |
|
|
|
it('Update view row with validation and invalid data FORM', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.FORM); |
|
|
|
await testUpdateViewRowWithValidationAndInvalidData(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// todo: Test webhooks of before and after update
|
|
|
|
// todo: Test webhooks of before and after update
|
|
|
|
// todo: Test with form view
|
|
|
|
// todo: Test with form view
|
|
|
|
|
|
|
|
|
|
|
|
const testUpdateViewRowWithValidationAndValidData = async (viewType: ViewTypes) => { |
|
|
|
const testUpdateViewRowWithValidationAndValidData = async ( |
|
|
|
|
|
|
|
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, { |
|
|
|
title: 'Email', |
|
|
|
title: 'Email', |
|
|
@ -963,77 +1036,82 @@ function viewRowTests() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.patch(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`) |
|
|
|
.patch( |
|
|
|
|
|
|
|
`/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({ |
|
|
|
[emailColumn.column_name]: 'valid@example.com', |
|
|
|
[emailColumn.column_name]: 'valid@example.com', |
|
|
|
}) |
|
|
|
}) |
|
|
|
.expect(200); |
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
const updatedRow = await getRow( |
|
|
|
const updatedRow = await getRow(context, { |
|
|
|
context, |
|
|
|
project, |
|
|
|
{project, |
|
|
|
|
|
|
|
table, |
|
|
|
table, |
|
|
|
id: response.body['Id']} |
|
|
|
id: response.body['Id'], |
|
|
|
); |
|
|
|
}); |
|
|
|
if (updatedRow[emailColumn.title] !== 'valid@example.com') { |
|
|
|
if (updatedRow[emailColumn.title] !== 'valid@example.com') { |
|
|
|
throw new Error('Wrong update'); |
|
|
|
throw new Error('Wrong update'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and valid data GALLERY', async function () { |
|
|
|
it('Update view row with validation and valid data GALLERY', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.GALLERY); |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and valid data GRID', async function () { |
|
|
|
it('Update view row with validation and valid data GRID', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.GRID); |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Update view row with validation and valid data FORM', async function () { |
|
|
|
it('Update view row with validation and valid data FORM', async function () { |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.FORM); |
|
|
|
await testUpdateViewRowWithValidationAndValidData(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testDeleteViewRow = async (viewType: ViewTypes) => { |
|
|
|
const testDeleteViewRow = async (viewType: ViewTypes) => { |
|
|
|
const table = await createTable(context, project); |
|
|
|
const table = await createTable(context, project); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await request(context.app) |
|
|
|
await request(context.app) |
|
|
|
.delete(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`) |
|
|
|
.delete( |
|
|
|
|
|
|
|
`/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 && Object.keys(deleteRow).length > 0) { |
|
|
|
if (deleteRow && Object.keys(deleteRow).length > 0) { |
|
|
|
console.log(deleteRow); |
|
|
|
console.log(deleteRow); |
|
|
|
throw new Error('Wrong delete'); |
|
|
|
throw new Error('Wrong delete'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Delete view row GALLERY', async function () { |
|
|
|
it('Delete view row GALLERY', async function () { |
|
|
|
await testDeleteViewRow(ViewTypes.GALLERY); |
|
|
|
await testDeleteViewRow(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Delete view row GRID', async function () { |
|
|
|
it('Delete view row GRID', async function () { |
|
|
|
await testDeleteViewRow(ViewTypes.GRID); |
|
|
|
await testDeleteViewRow(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Delete view row FORM', async function () { |
|
|
|
it('Delete view row FORM', async function () { |
|
|
|
await testDeleteViewRow(ViewTypes.FORM); |
|
|
|
await testDeleteViewRow(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testDeleteViewRowWithForiegnKeyConstraint = async (viewType: ViewTypes) => { |
|
|
|
const testDeleteViewRowWithForiegnKeyConstraint = async ( |
|
|
|
|
|
|
|
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, { |
|
|
|
table_name: 'Table2', |
|
|
|
table_name: 'Table2', |
|
|
@ -1046,9 +1124,9 @@ function viewRowTests() { |
|
|
|
type: 'hm', |
|
|
|
type: 'hm', |
|
|
|
}); |
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: table, |
|
|
|
table: table, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const row = await createRow(context, { project, table }); |
|
|
|
const row = await createRow(context, { project, table }); |
|
|
@ -1063,11 +1141,13 @@ function viewRowTests() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.delete(`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`) |
|
|
|
.delete( |
|
|
|
|
|
|
|
`/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) { |
|
|
|
throw new Error('Should not delete'); |
|
|
|
throw new Error('Should not delete'); |
|
|
|
} |
|
|
|
} |
|
|
@ -1079,19 +1159,19 @@ function viewRowTests() { |
|
|
|
) { |
|
|
|
) { |
|
|
|
throw new Error('Should give ltar foreign key error'); |
|
|
|
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 testDeleteViewRowWithForiegnKeyConstraint(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 testDeleteViewRowWithForiegnKeyConstraint(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 testDeleteViewRowWithForiegnKeyConstraint(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testViewRowExists = async (viewType: ViewTypes) => { |
|
|
|
const testViewRowExists = async (viewType: ViewTypes) => { |
|
|
|
const row = await getOneRow(context, { |
|
|
|
const row = await getOneRow(context, { |
|
|
@ -1099,9 +1179,9 @@ function viewRowTests() { |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
@ -1114,7 +1194,7 @@ function viewRowTests() { |
|
|
|
if (!response.body) { |
|
|
|
if (!response.body) { |
|
|
|
throw new Error('Should exist'); |
|
|
|
throw new Error('Should exist'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be true view row when it exists GALLERY', async function () { |
|
|
|
it('Exist should be true view row when it exists GALLERY', async function () { |
|
|
|
await testViewRowExists(ViewTypes.GALLERY); |
|
|
|
await testViewRowExists(ViewTypes.GALLERY); |
|
|
@ -1122,17 +1202,17 @@ function viewRowTests() { |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be true view row when it exists GRID', async function () { |
|
|
|
it('Exist should be true view row when it exists GRID', async function () { |
|
|
|
await testViewRowExists(ViewTypes.GRID); |
|
|
|
await testViewRowExists(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be true view row when it exists FORM', async function () { |
|
|
|
it('Exist should be true view row when it exists FORM', async function () { |
|
|
|
await testViewRowExists(ViewTypes.FORM); |
|
|
|
await testViewRowExists(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const testViewRowNotExists = async (viewType: ViewTypes) => { |
|
|
|
const testViewRowNotExists = async (viewType: ViewTypes) => { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: viewType |
|
|
|
type: viewType, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get( |
|
|
|
.get( |
|
|
@ -1144,61 +1224,69 @@ function viewRowTests() { |
|
|
|
if (response.body) { |
|
|
|
if (response.body) { |
|
|
|
throw new Error('Should not exist'); |
|
|
|
throw new Error('Should not exist'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be false view row when it does not exist GALLERY', async function () { |
|
|
|
it('Exist should be false view row when it does not exist GALLERY', async function () { |
|
|
|
await testViewRowNotExists(ViewTypes.GALLERY); |
|
|
|
await testViewRowNotExists(ViewTypes.GALLERY); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be false view row when it does not exist GRID', async function () { |
|
|
|
it('Exist should be false view row when it does not exist GRID', async function () { |
|
|
|
await testViewRowNotExists(ViewTypes.GRID); |
|
|
|
await testViewRowNotExists(ViewTypes.GRID); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Exist should be false view row when it does not exist FORM', async function () { |
|
|
|
it('Exist should be false view row when it does not exist FORM', async function () { |
|
|
|
await testViewRowNotExists(ViewTypes.FORM); |
|
|
|
await testViewRowNotExists(ViewTypes.FORM); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Export csv GRID', async function () { |
|
|
|
it('Export csv GRID', async function () { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: ViewTypes.GRID |
|
|
|
type: ViewTypes.GRID, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/csv`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/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); |
|
|
|
|
|
|
|
|
|
|
|
if(!response['header']['content-disposition'].includes("View-export.csv")){ |
|
|
|
if ( |
|
|
|
|
|
|
|
!response['header']['content-disposition'].includes('View-export.csv') |
|
|
|
|
|
|
|
) { |
|
|
|
console.log(response['header']['content-disposition']); |
|
|
|
console.log(response['header']['content-disposition']); |
|
|
|
throw new Error('Wrong file name'); |
|
|
|
throw new Error('Wrong file name'); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!response.text){ |
|
|
|
if (!response.text) { |
|
|
|
throw new Error('Wrong export'); |
|
|
|
throw new Error('Wrong export'); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Export excel GRID', async function () { |
|
|
|
it('Export excel GRID', async function () { |
|
|
|
const view = await createView(context, { |
|
|
|
const view = await createView(context, { |
|
|
|
title: 'View',
|
|
|
|
title: 'View', |
|
|
|
table: customerTable, |
|
|
|
table: customerTable, |
|
|
|
type: ViewTypes.GRID |
|
|
|
type: ViewTypes.GRID, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const response = await request(context.app) |
|
|
|
const response = await request(context.app) |
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/excel`) |
|
|
|
.get( |
|
|
|
|
|
|
|
`/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); |
|
|
|
|
|
|
|
|
|
|
|
if(!response['header']['content-disposition'].includes("View-export.xlsx")){ |
|
|
|
if ( |
|
|
|
|
|
|
|
!response['header']['content-disposition'].includes('View-export.xlsx') |
|
|
|
|
|
|
|
) { |
|
|
|
console.log(response['header']['content-disposition']); |
|
|
|
console.log(response['header']['content-disposition']); |
|
|
|
throw new Error('Wrong file name'); |
|
|
|
throw new Error('Wrong file name'); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!response.text){ |
|
|
|
if (!response.text) { |
|
|
|
throw new Error('Wrong export'); |
|
|
|
throw new Error('Wrong export'); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default function () { |
|
|
|
export default function () { |
|
|
|
describe('ViewRow', viewRowTests); |
|
|
|
describe.only('ViewRow', viewRowTests); |
|
|
|
} |
|
|
|
} |
|
|
|