import { schema } from '@osd/config-schema' ; import * as osdTestServer from '../../../test_helpers/osd_server' ; describe ( 'ui settings service' , ( ) => { describe ( 'routes' , ( ) => { let root ; beforeAll ( async ( ) => { root = osdTestServer . createRoot ( { plugins : { initialize : false } } ) ; const { uiSettings } = await root . setup ( ) ; uiSettings . register ( { custom : { value : '42' , schema : schema . string ( ) , } , } ) ; await root . start ( ) ; } , 30000 ) ; afterAll ( async ( ) => await root . shutdown ( ) ) ; describe ( 'set' , ( ) => { it ( 'validates value' , async ( ) => { const response = await osdTestServer . request . post ( root , '/api/opensearch-dashboards/settings/custom' ) . send ( { value : 100 } ) . expect ( 400 ) ; expect ( response . body . message ) . toBe ( '[validation [custom]]: expected value of type [string] but got [number]' ) ; } ) ; } ) ; describe ( 'set many' , ( ) => { it ( 'validates value' , async ( ) => { const response = await osdTestServer . request . post ( root , '/api/opensearch-dashboards/settings' ) . send ( { changes : { custom : 100 , foo : 'bar' } } ) . expect ( 400 ) ; expect ( response . body . message ) . toBe ( '[validation [custom]]: expected value of type [string] but got [number]' ) ; } ) ; } ) ; } ) ; } ) ;