Browse Source

chore(api): add unit test

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3814/head
Pranav C 2 years ago
parent
commit
5e7293451a
  1. 4
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  2. 48
      packages/nocodb/tests/unit/rest/tests/tableRow.test.ts

4
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -256,7 +256,7 @@ async function getGroupedDataList(model, view: View, req) {
try {
data = await nocoExecute(
requestObj,
await baseModel.list(listArgs),
await baseModel.groupedList({ ...listArgs, groupColumnId: req.params.columnId }),
{},
listArgs
);
@ -359,7 +359,7 @@ router.get(
router.get(
'/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/grouped',
'/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/group/:columnId',
apiMetrics,
ncMetaAclMw(groupedDataList, 'groupedDataList')
);

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

@ -2110,6 +2110,54 @@ function tableTest() {
throw new Error('Wrong error message');
}
})
it.only('Grouped api', async function () {
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
);
const filmTable = await getTable({project: sakilaProject, name: 'film'})
const filmColumns = await filmTable.getColumns();
console.log(firstNameColumn,filmTable,filmColumns)
// const rollupColumn = await createRollupColumn(context, {
// project: sakilaProject,
// title: 'Rollup',
// rollupFunction: 'count',
// table: customerTable,
// relatedTableName: 'rental',
// relatedTableColumnTitle: 'RentalDate',
// });
//
// const visibleColumns = [firstNameColumn];
// const sortInfo = `-FirstName, +${rollupColumn.title}`;
//
// const response = await request(context.app)
// .get(
// `/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/group/`
// )
// .set('xc-auth', context.token)
// .query({
// fields: visibleColumns.map((c) => c.title),
// sort: sortInfo,
// column_name: firstNameColumn.column_name,
// })
// .expect(200);
//
// if (
// response.body.list[4]['first_name'] !== 'WILLIE' ||
// response.body.list[4]['count'] !== 2
// )
// throw new Error('Wrong groupby');
});
}
export default function () {

Loading…
Cancel
Save