CM: Add e2e test for resetted relations after server restart

This commit is contained in:
Gustav Hansen 2022-02-28 13:11:46 +01:00
parent 458be60f41
commit e88cce8924

View File

@ -0,0 +1,75 @@
'use strict';
// Helpers.
const { createTestBuilder } = require('../../../../../../test/helpers/builder');
const { createStrapiInstance } = require('../../../../../../test/helpers/strapi');
const form = require('../../../../../../test/helpers/generators');
const { createAuthRequest } = require('../../../../../../test/helpers/request');
const builder = createTestBuilder();
let strapi;
let rq;
const restart = async () => {
await strapi.destroy();
strapi = await createStrapiInstance();
rq = await createAuthRequest({ strapi });
};
describe('Content Manager - Hide relations', () => {
beforeAll(async () => {
await builder.addContentTypes([form.article]).build();
strapi = await createStrapiInstance();
rq = await createAuthRequest({ strapi });
});
afterAll(async () => {
await strapi.destroy();
await builder.cleanup();
});
test('Hide relations', async () => {
await rq({
url: '/content-manager/content-types/api::article.article/configuration',
method: 'PUT',
body: {
layouts: {
edit: [],
editRelations: [],
list: [],
},
},
});
const { body } = await rq({
url: '/content-manager/content-types/api::article.article/configuration',
method: 'GET',
});
expect(body.data.contentType.layouts.editRelations).toStrictEqual([]);
});
test('Hide relations after server restart', async () => {
await rq({
url: '/content-manager/content-types/api::article.article/configuration',
method: 'PUT',
body: {
layouts: {
edit: [],
editRelations: [],
list: [],
},
},
});
await restart();
const { body } = await rq({
url: '/content-manager/content-types/api::article.article/configuration',
method: 'GET',
});
expect(body.data.contentType.layouts.editRelations).toStrictEqual([]);
});
});