mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Allow setting CT's config from the CTB services
This commit is contained in:
		
							parent
							
								
									132def5d57
								
							
						
					
					
						commit
						b11623d365
					
				| @ -1,5 +1,7 @@ | |||||||
| 'use strict'; | 'use strict'; | ||||||
| 
 | 
 | ||||||
|  | const { omit } = require('lodash/fp'); | ||||||
|  | 
 | ||||||
| const { createStrapiInstance } = require('../../../../../../test/helpers/strapi'); | const { createStrapiInstance } = require('../../../../../../test/helpers/strapi'); | ||||||
| const { createTestBuilder } = require('../../../../../../test/helpers/builder'); | const { createTestBuilder } = require('../../../../../../test/helpers/builder'); | ||||||
| const { createAuthRequest } = require('../../../../../../test/helpers/request'); | const { createAuthRequest } = require('../../../../../../test/helpers/request'); | ||||||
| @ -22,6 +24,16 @@ const product = { | |||||||
|       minLength: 4, |       minLength: 4, | ||||||
|       maxLength: 30, |       maxLength: 30, | ||||||
|     }, |     }, | ||||||
|  |     hiddenAttribute: { | ||||||
|  |       type: 'string', | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   config: { | ||||||
|  |     attributes: { | ||||||
|  |       hiddenAttribute: { | ||||||
|  |         hidden: true, | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|   }, |   }, | ||||||
|   displayName: 'Product', |   displayName: 'Product', | ||||||
|   singularName: 'product', |   singularName: 'product', | ||||||
| @ -47,6 +59,7 @@ describe('CM API - Basic', () => { | |||||||
|     const product = { |     const product = { | ||||||
|       name: 'Product 1', |       name: 'Product 1', | ||||||
|       description: 'Product description', |       description: 'Product description', | ||||||
|  |       hiddenAttribute: 'Secret value', | ||||||
|     }; |     }; | ||||||
|     const res = await rq({ |     const res = await rq({ | ||||||
|       method: 'POST', |       method: 'POST', | ||||||
| @ -55,7 +68,8 @@ describe('CM API - Basic', () => { | |||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     expect(res.statusCode).toBe(200); |     expect(res.statusCode).toBe(200); | ||||||
|     expect(res.body).toMatchObject(product); |     expect(res.body).toMatchObject(omit('hiddenAttribute', product)); | ||||||
|  |     expect(res.body).not.toHaveProperty('hiddenAttribute'); | ||||||
|     expect(res.body.publishedAt).toBeUndefined(); |     expect(res.body.publishedAt).toBeUndefined(); | ||||||
|     data.products.push(res.body); |     data.products.push(res.body); | ||||||
|   }); |   }); | ||||||
| @ -84,6 +98,7 @@ describe('CM API - Basic', () => { | |||||||
|     const product = { |     const product = { | ||||||
|       name: 'Product 1 updated', |       name: 'Product 1 updated', | ||||||
|       description: 'Updated Product description', |       description: 'Updated Product description', | ||||||
|  |       hiddenAttribute: 'Secret value', | ||||||
|     }; |     }; | ||||||
|     const res = await rq({ |     const res = await rq({ | ||||||
|       method: 'PUT', |       method: 'PUT', | ||||||
| @ -92,7 +107,7 @@ describe('CM API - Basic', () => { | |||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     expect(res.statusCode).toBe(200); |     expect(res.statusCode).toBe(200); | ||||||
|     expect(res.body).toMatchObject(product); |     expect(res.body).toMatchObject(omit('hiddenAttribute', product)); | ||||||
|     expect(res.body.id).toEqual(data.products[0].id); |     expect(res.body.id).toEqual(data.products[0].id); | ||||||
|     expect(res.body.publishedAt).toBeUndefined(); |     expect(res.body.publishedAt).toBeUndefined(); | ||||||
|     data.products[0] = res.body; |     data.products[0] = res.body; | ||||||
|  | |||||||
| @ -54,6 +54,7 @@ module.exports = function createComponentBuilder() { | |||||||
|         .set(['info', 'icon'], infos.icon) |         .set(['info', 'icon'], infos.icon) | ||||||
|         .set(['info', 'description'], infos.description) |         .set(['info', 'description'], infos.description) | ||||||
|         .set('pluginOptions', infos.pluginOptions) |         .set('pluginOptions', infos.pluginOptions) | ||||||
|  |         .set('config', infos.config) | ||||||
|         .setAttributes(this.convertAttributes(infos.attributes)); |         .setAttributes(this.convertAttributes(infos.attributes)); | ||||||
| 
 | 
 | ||||||
|       if (this.components.size === 0) { |       if (this.components.size === 0) { | ||||||
|  | |||||||
| @ -105,6 +105,7 @@ module.exports = function createComponentBuilder() { | |||||||
|         }) |         }) | ||||||
|         .set('options', { draftAndPublish: infos.draftAndPublish || false }) |         .set('options', { draftAndPublish: infos.draftAndPublish || false }) | ||||||
|         .set('pluginOptions', infos.pluginOptions) |         .set('pluginOptions', infos.pluginOptions) | ||||||
|  |         .set('config', infos.config) | ||||||
|         .setAttributes(this.convertAttributes(infos.attributes)); |         .setAttributes(this.convertAttributes(infos.attributes)); | ||||||
| 
 | 
 | ||||||
|       Object.keys(infos.attributes).forEach(key => { |       Object.keys(infos.attributes).forEach(key => { | ||||||
|  | |||||||
| @ -25,6 +25,7 @@ module.exports = function createBuilder() { | |||||||
|       filename: compo.__filename__, |       filename: compo.__filename__, | ||||||
|       dir: join(strapi.dirs.components, compo.category), |       dir: join(strapi.dirs.components, compo.category), | ||||||
|       schema: compo.__schema__, |       schema: compo.__schema__, | ||||||
|  |       config: compo.config, | ||||||
|     }; |     }; | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
| @ -47,6 +48,7 @@ module.exports = function createBuilder() { | |||||||
|       filename: 'schema.json', |       filename: 'schema.json', | ||||||
|       dir, |       dir, | ||||||
|       schema: contentType.__schema__, |       schema: contentType.__schema__, | ||||||
|  |       config: contentType.config, | ||||||
|     }; |     }; | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -231,6 +231,7 @@ module.exports = function createSchemaHandler(infos) { | |||||||
|             options: state.schema.options, |             options: state.schema.options, | ||||||
|             pluginOptions: state.schema.pluginOptions, |             pluginOptions: state.schema.pluginOptions, | ||||||
|             attributes: state.schema.attributes, |             attributes: state.schema.attributes, | ||||||
|  |             config: state.schema.config, | ||||||
|           }, |           }, | ||||||
|           { spaces: 2 } |           { spaces: 2 } | ||||||
|         ); |         ); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Convly
						Convly