mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.9 KiB
82 lines
1.9 KiB
2 years ago
|
import request from 'supertest';
|
||
2 years ago
|
import Project from '../../../src/lib/models/Project';
|
||
2 years ago
|
|
||
2 years ago
|
const sakilaProjectConfig = (context) => {
|
||
|
let base;
|
||
|
|
||
2 years ago
|
if (
|
||
|
context.sakilaDbConfig.client === 'mysql2' ||
|
||
|
context.sakilaDbConfig.client === 'pg'
|
||
|
) {
|
||
2 years ago
|
base = {
|
||
|
type: context.sakilaDbConfig.client,
|
||
|
config: {
|
||
|
client: context.sakilaDbConfig.client,
|
||
2 years ago
|
connection: context.sakilaDbConfig.connection,
|
||
|
},
|
||
2 years ago
|
};
|
||
|
} else {
|
||
|
base = {
|
||
|
type: context.sakilaDbConfig.client,
|
||
2 years ago
|
config: {
|
||
2 years ago
|
client: context.sakilaDbConfig.client,
|
||
2 years ago
|
connection: {
|
||
2 years ago
|
client: context.sakilaDbConfig.client,
|
||
|
connection: context.sakilaDbConfig.connection,
|
||
2 years ago
|
},
|
||
|
},
|
||
2 years ago
|
};
|
||
|
}
|
||
|
|
||
|
base = {
|
||
2 years ago
|
...base,
|
||
2 years ago
|
inflection_column: 'camelize',
|
||
|
inflection_table: 'camelize',
|
||
|
};
|
||
|
|
||
|
return {
|
||
|
title: 'sakila',
|
||
|
bases: [base],
|
||
|
external: true,
|
||
2 years ago
|
};
|
||
2 years ago
|
};
|
||
2 years ago
|
|
||
|
const defaultProjectValue = {
|
||
|
title: 'Title',
|
||
|
};
|
||
|
|
||
2 years ago
|
const defaultSharedBaseValue = {
|
||
|
roles: 'viewer',
|
||
2 years ago
|
password: 'password123',
|
||
2 years ago
|
};
|
||
|
|
||
|
const createSharedBase = async (app, token, project, sharedBaseArgs = {}) => {
|
||
|
await request(app)
|
||
|
.post(`/api/v1/db/meta/projects/${project.id}/shared`)
|
||
|
.set('xc-auth', token)
|
||
|
.send({
|
||
|
...defaultSharedBaseValue,
|
||
|
...sharedBaseArgs,
|
||
|
});
|
||
|
};
|
||
|
|
||
2 years ago
|
const createSakilaProject = async (context) => {
|
||
2 years ago
|
const response = await request(context.app)
|
||
2 years ago
|
.post('/api/v1/db/meta/projects/')
|
||
2 years ago
|
.set('xc-auth', context.token)
|
||
2 years ago
|
.send(sakilaProjectConfig(context));
|
||
2 years ago
|
|
||
2 years ago
|
return (await Project.getByTitleOrId(response.body.id)) as Project;
|
||
2 years ago
|
};
|
||
|
|
||
2 years ago
|
const createProject = async (context, projectArgs = defaultProjectValue) => {
|
||
|
const response = await request(context.app)
|
||
2 years ago
|
.post('/api/v1/db/meta/projects/')
|
||
2 years ago
|
.set('xc-auth', context.token)
|
||
2 years ago
|
.send(projectArgs);
|
||
2 years ago
|
|
||
2 years ago
|
return (await Project.getByTitleOrId(response.body.id)) as Project;
|
||
2 years ago
|
};
|
||
|
|
||
2 years ago
|
export { createProject, createSharedBase, createSakilaProject };
|