Browse Source

test(nocodb): include kanban view test in viewRow.test.ts

pull/3563/head
Wing-Kam Wong 2 years ago
parent
commit
7e5b6b43e3
  1. 47
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

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

@ -35,13 +35,21 @@ const isColumnsCorrectInResponse = (row, columns: ColumnType[]) => {
function viewRowTests() { function viewRowTests() {
let context; let context;
// projects
let project: Project; let project: Project;
let sakilaProject: Project; let sakilaProject: Project;
// models
let customerTable: Model; let customerTable: Model;
let filmTable: Model;
// columns
let customerColumns; let customerColumns;
let filmColumns;
// views
let customerGridView: View; let customerGridView: View;
let customerGalleryView: View; let customerGalleryView: View;
let customerFormView: View; let customerFormView: View;
// use film table because it has single select field
let filmKanbanView: View;
beforeEach(async function () { beforeEach(async function () {
context = await init(); context = await init();
@ -67,9 +75,20 @@ function viewRowTests() {
table: customerTable, table: customerTable,
type: ViewTypes.FORM, type: ViewTypes.FORM,
}); });
filmTable = await getTable({
project: sakilaProject,
name: 'film',
});
filmColumns = await filmTable.getColumns();
filmKanbanView = await createView(context, {
title: 'Film Kanban',
table: customerTable,
type: ViewTypes.KANBAN,
});
}); });
const testGetViewRowListGallery = 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}`
@ -86,16 +105,34 @@ function viewRowTests() {
} }
}; };
const testGetViewRowListKanban = async (view: View) => {
const ratingColumn = filmColumns.find((c) => c.column_name === 'rating');
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/Film/group/${ratingColumn.id}`
)
.set('xc-auth', context.token)
.expect(200);
if (response.body.length !== 6) {
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 testGetViewRowList(customerGalleryView);
});
it('Get view row list kanban', async () => {
await testGetViewRowListKanban(filmKanbanView);
}); });
it('Get view row list form', async () => { it('Get view row list form', async () => {
await testGetViewRowListGallery(customerFormView); await testGetViewRowList(customerFormView);
}); });
it('Get view row list grid', async () => { it('Get view row list grid', async () => {
await testGetViewRowListGallery(customerGridView); await testGetViewRowList(customerGridView);
}); });
const testGetViewDataListWithRequiredColumns = async (view: View) => { const testGetViewDataListWithRequiredColumns = async (view: View) => {
@ -1288,5 +1325,5 @@ function viewRowTests() {
} }
export default function () { export default function () {
describe.only('ViewRow', viewRowTests); describe('ViewRow', viewRowTests);
} }

Loading…
Cancel
Save