|
|
|
@ -17,6 +17,7 @@ import {
|
|
|
|
|
getOneRow, |
|
|
|
|
getRow, |
|
|
|
|
listRow, |
|
|
|
|
createBulkRows, |
|
|
|
|
} from '../../factory/row'; |
|
|
|
|
import { isMysql, isSqlite } from '../../init/db'; |
|
|
|
|
import Model from '../../../../src/lib/models/Model'; |
|
|
|
@ -58,6 +59,7 @@ function tableTest() {
|
|
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
|
|
|
|
|
|
if (response.body.list.length !== pageInfo.pageSize) { |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -79,6 +81,7 @@ function tableTest() {
|
|
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
|
|
|
|
|
|
if (response.body.list.length !== pageInfo.pageSize) { |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -105,6 +108,7 @@ function tableTest() {
|
|
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
|
|
|
|
|
|
if (response.body.list.length !== pageInfo.pageSize) { |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -158,6 +162,7 @@ function tableTest() {
|
|
|
|
|
const pageInfo = response.body.pageInfo; |
|
|
|
|
|
|
|
|
|
if (response.body.list.length !== pageInfo.pageSize) { |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -292,8 +297,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (response.body.pageInfo.totalRows !== 24) |
|
|
|
|
if (response.body.pageInfo.totalRows !== 24){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
response.body.list.forEach((row) => { |
|
|
|
|
if (row[lookupColumn.title] !== 'AARON') throw new Error('Wrong filter'); |
|
|
|
@ -325,8 +332,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (response.body.pageInfo.totalRows !== 158) |
|
|
|
|
if (response.body.pageInfo.totalRows !== 158){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Get nested sorted filtered table data list with a lookup column', async function () { |
|
|
|
@ -391,8 +400,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (response.body.pageInfo.totalRows !== 9133) |
|
|
|
|
if (response.body.pageInfo.totalRows !== 9133){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (response.body.list[0][lookupColumn.title] !== 'ANDREW') |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
@ -411,8 +422,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 9133) |
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 9133){ |
|
|
|
|
console.log(ascResponse.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.list[0][lookupColumn.title] !== 'AARON') { |
|
|
|
|
console.log(ascResponse.body.list[0][lookupColumn.title]); |
|
|
|
@ -433,8 +446,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (descResponse.body.pageInfo.totalRows !== 9133) |
|
|
|
|
if (descResponse.body.pageInfo.totalRows !== 9133){ |
|
|
|
|
console.log(descResponse.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (descResponse.body.list[0][lookupColumn.title] !== 'ZACHARY') |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
@ -513,11 +528,15 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (response.body.pageInfo.totalRows !== 594) |
|
|
|
|
if (response.body.pageInfo.totalRows !== 594){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (response.body.list[0][rollupColumn.title] !== 32) |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
if (response.body.list[0][rollupColumn.title] !== 32){ |
|
|
|
|
console.log(response.body.list[0]) |
|
|
|
|
throw new Error('Wrong filter response 0'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const ascResponse = await request(context.app) |
|
|
|
|
.get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}`) |
|
|
|
@ -537,12 +556,14 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 594) |
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 594){ |
|
|
|
|
console.log(ascResponse.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.list[0][rollupColumn.title] !== 12) { |
|
|
|
|
console.log(ascResponse.body.list[0][rollupColumn.title]); |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
throw new Error('Wrong filter ascResponse 0'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
@ -550,7 +571,7 @@ function tableTest() {
|
|
|
|
|
'1308 Sumy Loop' |
|
|
|
|
) { |
|
|
|
|
console.log(ascResponse.body.list[1]); |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
throw new Error('Wrong filter ascResponse 1'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const descResponse = await request(context.app) |
|
|
|
@ -571,18 +592,22 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (descResponse.body.pageInfo.totalRows !== 594) |
|
|
|
|
if (descResponse.body.pageInfo.totalRows !== 594){ |
|
|
|
|
console.log(descResponse.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (descResponse.body.list[0][rollupColumn.title] !== 46) |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
if (descResponse.body.list[0][rollupColumn.title] !== 46){ |
|
|
|
|
console.log(descResponse.body.list[0]); |
|
|
|
|
throw new Error('Wrong filter descResponse 0'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
descResponse.body.list[2][addressColumn.title]['Address'] !== |
|
|
|
|
'1479 Rustenburg Boulevard' |
|
|
|
|
) { |
|
|
|
|
console.log(descResponse.body.list[2]); |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
throw new Error('Wrong filter descResponse 2'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -666,8 +691,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 594) |
|
|
|
|
if (ascResponse.body.pageInfo.totalRows !== 594){ |
|
|
|
|
console.log(ascResponse.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ascResponse.body.list[0][rollupColumn.title] !== 12) { |
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
@ -1268,7 +1295,7 @@ function tableTest() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Max 10 rows will be inserted in sqlite
|
|
|
|
|
if (isSqlite(context) && response.body.length !== 10) { |
|
|
|
|
if ((isSqlite(context) && rows.length !== rowAttributes.length)) { |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -1293,21 +1320,21 @@ function tableTest() {
|
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
const rows = await listRow({ project, table }); |
|
|
|
|
|
|
|
|
|
// Mysql will not return the batched inserted rows
|
|
|
|
|
if (!isMysql(context)) { |
|
|
|
|
if ( |
|
|
|
|
!isSqlite(context) && |
|
|
|
|
response.body.length !== rowAttributes.length && |
|
|
|
|
rows.length !== rowAttributes.length |
|
|
|
|
) { |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Max 10 rows will be inserted in sqlite
|
|
|
|
|
if (isSqlite(context) && response.body.length !== 10) { |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
|
} |
|
|
|
|
) { |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Max 10 rows will be inserted in sqlite
|
|
|
|
|
if (isSqlite(context) && rows.length !== rowAttributes.length) { |
|
|
|
|
console.log(response.body) |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (rows.length !== rowAttributes.length) { |
|
|
|
|
throw new Error('Wrong number of rows inserted'); |
|
|
|
@ -1316,17 +1343,24 @@ function tableTest() {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Bulk update', async function () { |
|
|
|
|
// todo: Find why bulk update in sqlite is hanging
|
|
|
|
|
if(isSqlite(context)) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
const table = await createTable(context, project); |
|
|
|
|
const columns = await table.getColumns(); |
|
|
|
|
|
|
|
|
|
const arr = Array(120) |
|
|
|
|
const rowAttributes = Array(400) |
|
|
|
|
.fill(0) |
|
|
|
|
.map((_, index) => index); |
|
|
|
|
for (const index of arr) { |
|
|
|
|
await createRow(context, { project, table, index }); |
|
|
|
|
} |
|
|
|
|
.map((index) => generateDefaultRowAttributes({ columns, index })); |
|
|
|
|
|
|
|
|
|
await createBulkRows(context, { |
|
|
|
|
project, |
|
|
|
|
table, |
|
|
|
|
values: rowAttributes |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const rows = await listRow({ project, table }); |
|
|
|
|
|
|
|
|
|
await request(context.app) |
|
|
|
|
.patch(`/api/v1/db/data/bulk/noco/${project.id}/${table.id}`) |
|
|
|
|
.set('xc-auth', context.token) |
|
|
|
@ -1334,7 +1368,6 @@ function tableTest() {
|
|
|
|
|
rows.map((row) => ({ title: `new-${row['Title']}`, id: row['Id'] })) |
|
|
|
|
) |
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
const updatedRows: Array<any> = await listRow({ project, table }); |
|
|
|
|
if (!updatedRows.every((row) => row['Title'].startsWith('new-'))) { |
|
|
|
|
throw new Error('Wrong number of rows updated'); |
|
|
|
@ -1342,14 +1375,23 @@ function tableTest() {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Bulk delete', async function () { |
|
|
|
|
// todo: Find why bulk delete in sqlite is hanging
|
|
|
|
|
if(isSqlite(context)) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const table = await createTable(context, project); |
|
|
|
|
const columns = await table.getColumns(); |
|
|
|
|
|
|
|
|
|
const arr = Array(120) |
|
|
|
|
const rowAttributes = Array(400) |
|
|
|
|
.fill(0) |
|
|
|
|
.map((_, index) => index); |
|
|
|
|
for (const index of arr) { |
|
|
|
|
await createRow(context, { project, table, index }); |
|
|
|
|
} |
|
|
|
|
.map((index) => generateDefaultRowAttributes({ columns, index })); |
|
|
|
|
|
|
|
|
|
await createBulkRows(context, { |
|
|
|
|
project, |
|
|
|
|
table, |
|
|
|
|
values: rowAttributes |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const rows = await listRow({ project, table }); |
|
|
|
|
|
|
|
|
@ -1856,6 +1898,10 @@ function tableTest() {
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
it('Exclude list hm', async () => { |
|
|
|
|
// todo: Find why sqlite not working with this
|
|
|
|
|
if(isSqlite(context)) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
const rowId = 1; |
|
|
|
|
const rentalListColumn = (await customerTable.getColumns()).find( |
|
|
|
|
(column) => column.title === 'Rental List' |
|
|
|
@ -1867,6 +1913,7 @@ function tableTest() {
|
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if(response.body.pageInfo.totalRows !== 16012){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -1887,6 +1934,7 @@ function tableTest() {
|
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
if(response.body.pageInfo.totalRows !== 16012 ){ |
|
|
|
|
console.log(response.body.pageInfo) |
|
|
|
|
throw new Error('Wrong number of rows') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|