feat: write REST API endpoint to create step
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import Role from '../../src/models/role';
|
||||
import { createPermission } from './permission';
|
||||
|
||||
export const createRole = async (params = {}) => {
|
||||
const name = faker.lorem.word();
|
||||
@@ -16,3 +17,81 @@ export const createRole = async (params = {}) => {
|
||||
|
||||
return role;
|
||||
};
|
||||
|
||||
export const createAdminRole = async (params = {}) => {
|
||||
const adminRole = await createRole({ ...params, name: 'Admin' });
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'read',
|
||||
subject: 'Flow',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'create',
|
||||
subject: 'Flow',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'update',
|
||||
subject: 'Flow',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'delete',
|
||||
subject: 'Flow',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'publish',
|
||||
subject: 'Flow',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'read',
|
||||
subject: 'Connection',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'create',
|
||||
subject: 'Connection',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'update',
|
||||
subject: 'Connection',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'delete',
|
||||
subject: 'Connection',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'read',
|
||||
subject: 'Execution',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'create',
|
||||
subject: 'Execution',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
roleId: adminRole.id,
|
||||
action: 'update',
|
||||
subject: 'Execution',
|
||||
});
|
||||
|
||||
return adminRole;
|
||||
};
|
||||
|
26
packages/backend/test/mocks/rest/api/v1/flows/create-step.js
Normal file
26
packages/backend/test/mocks/rest/api/v1/flows/create-step.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const createStepMock = async (step) => {
|
||||
const data = {
|
||||
id: step.id,
|
||||
type: step.type || 'action',
|
||||
key: step.key || null,
|
||||
appKey: step.appKey || null,
|
||||
iconUrl: step.iconUrl || null,
|
||||
webhookUrl: step.webhookUrl || null,
|
||||
status: step.status || 'incomplete',
|
||||
position: step.position,
|
||||
parameters: step.parameters || {},
|
||||
};
|
||||
|
||||
return {
|
||||
data,
|
||||
meta: {
|
||||
type: 'Step',
|
||||
count: 1,
|
||||
isArray: false,
|
||||
currentPage: null,
|
||||
totalPages: null,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default createStepMock;
|
Reference in New Issue
Block a user