mirror of
https://github.com/strapi/strapi.git
synced 2025-11-26 07:01:14 +00:00
test: can set non visible attribute as the default sort of CT
This commit is contained in:
parent
8b17c0ded6
commit
fc22534f01
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
|
const { set } = require('lodash/fp');
|
||||||
const { createTestBuilder } = require('api-tests/builder');
|
const { createTestBuilder } = require('api-tests/builder');
|
||||||
const { createStrapiInstance } = require('api-tests/strapi');
|
const { createStrapiInstance } = require('api-tests/strapi');
|
||||||
const form = require('api-tests/generators');
|
const form = require('api-tests/generators');
|
||||||
@ -16,9 +17,16 @@ const restart = async () => {
|
|||||||
rq = await createAuthRequest({ strapi });
|
rq = await createAuthRequest({ strapi });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set a new attribute to form.article
|
||||||
|
const ct = set('attributes.nonVisible', {
|
||||||
|
type: 'string',
|
||||||
|
visible: false,
|
||||||
|
writable: true,
|
||||||
|
})(form.article);
|
||||||
|
|
||||||
describe('Content Manager - Configuration', () => {
|
describe('Content Manager - Configuration', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await builder.addContentTypes([form.article]).build();
|
await builder.addContentTypes([ct]).build();
|
||||||
|
|
||||||
strapi = await createStrapiInstance();
|
strapi = await createStrapiInstance();
|
||||||
rq = await createAuthRequest({ strapi });
|
rq = await createAuthRequest({ strapi });
|
||||||
@ -148,4 +156,24 @@ describe('Content Manager - Configuration', () => {
|
|||||||
]);
|
]);
|
||||||
expect(body.data.contentType.layouts.list).toStrictEqual(['id', 'title', 'author']);
|
expect(body.data.contentType.layouts.list).toStrictEqual(['id', 'title', 'author']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Update list non visible attribute as default sort', async () => {
|
||||||
|
// Get current config
|
||||||
|
const { body } = await rq({
|
||||||
|
url: '/content-manager/content-types/api::article.article/configuration',
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
|
||||||
|
// set default sort
|
||||||
|
const configuration = set('contentType.settings.defaultSortBy', 'nonVisible', body.data);
|
||||||
|
|
||||||
|
const res = await rq({
|
||||||
|
url: '/content-manager/content-types/api::article.article/configuration',
|
||||||
|
method: 'PUT',
|
||||||
|
body: { settings: configuration.contentType.settings },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.statusCode).toBe(200);
|
||||||
|
expect(res.body.data.contentType.settings.defaultSortBy).toBe('nonVisible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user