mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 06:50:51 +00:00
Merge pull request #12690 from strapi/fix/edit-relations-restart
CM: Fix sync layouts in case no relation is set
This commit is contained in:
commit
086c449fbe
@ -138,7 +138,9 @@ function syncLayouts(configuration, schema) {
|
|||||||
list: cleanList.length > 0 ? cleanList : createDefaultListLayout(schema),
|
list: cleanList.length > 0 ? cleanList : createDefaultListLayout(schema),
|
||||||
edit: cleanEdit.length > 0 ? cleanEdit : createDefaultEditLayout(schema),
|
edit: cleanEdit.length > 0 ? cleanEdit : createDefaultEditLayout(schema),
|
||||||
editRelations:
|
editRelations:
|
||||||
cleanEditRelations.length > 0 ? cleanEditRelations : createDefaultEditRelationsLayout(schema),
|
editRelations.length === 0 || cleanEditRelations.length > 0
|
||||||
|
? cleanEditRelations
|
||||||
|
: createDefaultEditRelationsLayout(schema),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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([]);
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user