fix tests

Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
Pierre Noël 2020-06-10 17:53:11 +02:00 committed by Alexandre Bodin
parent 3aec039698
commit 2339c6b8f7
2 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,7 @@
'use strict';
const _ = require('lodash');
const { registerAndLogin } = require('../../../test/helpers/auth');
const { createAuthRequest } = require('../../../test/helpers/request');
@ -18,6 +20,13 @@ describe('Role CRUD End to End', () => {
});
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(res.body.data).toMatchSnapshot();
});
});

View File

@ -6,17 +6,28 @@
const { registerAndLogin } = require('../../../test/helpers/auth');
const { createAuthRequest } = require('../../../test/helpers/request');
const waitRestart = require('../../../test/helpers/waitRestart');
const createModelsUtils = require('../../../test/helpers/models');
let rq;
let modelsUtils;
describe('Content Type Builder - Content types', () => {
beforeAll(async () => {
const token = await registerAndLogin();
rq = createAuthRequest(token);
modelsUtils = createModelsUtils({ rq });
}, 60000);
afterEach(() => waitRestart());
afterAll(async () => {
await modelsUtils.deleteContentTypes([
'test-collection-type',
'test-collection',
'test-single-type',
]);
}, 60000);
describe('Collection Types', () => {
const collectionTypeUID = 'application::test-collection-type.test-collection-type';