'use strict'; const _ = require('lodash'); const { createAuthRequest } = require('../../../test/helpers/request'); const { createStrapiInstance } = require('../../../test/helpers/strapi'); describe('Role CRUD End to End', () => { let rq; let strapi; beforeAll(async () => { strapi = await createStrapiInstance(); rq = await createAuthRequest({ strapi }); }, 60000); afterAll(async () => { await strapi.destroy(); }); test('Can get the existing permissions', async () => { let res = await rq({ url: '/admin/permissions', method: 'GET', }); expect(res.statusCode).toBe(200); // 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(); expect(sortedData).toMatchSnapshot(); }); });