2020-06-09 11:48:49 +02:00
|
|
|
'use strict';
|
|
|
|
|
2020-06-10 17:53:11 +02:00
|
|
|
const _ = require('lodash');
|
|
|
|
|
2020-06-04 18:30:26 +02:00
|
|
|
const { registerAndLogin } = require('../../../test/helpers/auth');
|
|
|
|
const { createAuthRequest } = require('../../../test/helpers/request');
|
|
|
|
|
|
|
|
let rq;
|
|
|
|
|
|
|
|
describe('Role CRUD End to End', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const token = await registerAndLogin();
|
|
|
|
rq = createAuthRequest(token);
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
test('Can get the existing permissions', async () => {
|
|
|
|
let res = await rq({
|
|
|
|
url: '/admin/permissions',
|
|
|
|
method: 'GET',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
2020-06-10 17:53:11 +02:00
|
|
|
|
|
|
|
// Data is sorted to avoid error with snapshot when the data is not in the same order
|
|
|
|
const sortedData = _.cloneDeep(res.body.data);
|
|
|
|
Object.keys(sortedData.sections).forEach(sectionName => {
|
|
|
|
sortedData.sections[sectionName] = _.sortBy(sortedData.sections[sectionName], ['action']);
|
|
|
|
});
|
|
|
|
sortedData.conditions = sortedData.conditions.sort();
|
2020-07-01 19:11:04 +02:00
|
|
|
expect(sortedData).toMatchSnapshot();
|
2020-06-04 18:30:26 +02:00
|
|
|
});
|
|
|
|
});
|