test(create-step): use non-admin user
This commit is contained in:
@@ -5,7 +5,6 @@ import request from 'supertest';
|
|||||||
import app from '../../../../app.js';
|
import app from '../../../../app.js';
|
||||||
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id.js';
|
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id.js';
|
||||||
import { createUser } from '../../../../../test/factories/user.js';
|
import { createUser } from '../../../../../test/factories/user.js';
|
||||||
import { createAdminRole } from '../../../../../test/factories/role.js';
|
|
||||||
import { createFlow } from '../../../../../test/factories/flow.js';
|
import { createFlow } from '../../../../../test/factories/flow.js';
|
||||||
import { createStep } from '../../../../../test/factories/step.js';
|
import { createStep } from '../../../../../test/factories/step.js';
|
||||||
import createStepMock from '../../../../../test/mocks/rest/api/v1/flows/create-step.js';
|
import createStepMock from '../../../../../test/mocks/rest/api/v1/flows/create-step.js';
|
||||||
@@ -15,8 +14,19 @@ describe('POST /api/v1/flows/:flowId/steps', () => {
|
|||||||
let currentUser, flow, triggerStep, token;
|
let currentUser, flow, triggerStep, token;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const adminRole = await createAdminRole();
|
currentUser = await createUser();
|
||||||
currentUser = await createUser({ roleId: adminRole.id });
|
|
||||||
|
await createPermission({
|
||||||
|
roleId: currentUser.roleId,
|
||||||
|
subject: 'Flow',
|
||||||
|
action: 'read',
|
||||||
|
});
|
||||||
|
|
||||||
|
await createPermission({
|
||||||
|
roleId: currentUser.roleId,
|
||||||
|
subject: 'Flow',
|
||||||
|
action: 'update',
|
||||||
|
});
|
||||||
|
|
||||||
flow = await createFlow({ userId: currentUser.id });
|
flow = await createFlow({ userId: currentUser.id });
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import Role from '../../src/models/role';
|
import Role from '../../src/models/role';
|
||||||
import { createPermission } from './permission';
|
|
||||||
|
|
||||||
export const createRole = async (params = {}) => {
|
export const createRole = async (params = {}) => {
|
||||||
const name = faker.lorem.word();
|
const name = faker.lorem.word();
|
||||||
@@ -17,81 +16,3 @@ export const createRole = async (params = {}) => {
|
|||||||
|
|
||||||
return role;
|
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;
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user