@@ -14,6 +14,7 @@ import { Drizzle } from '../../../src/db/createConnection';
1414import { getApp } from '../../../src/app' ;
1515import { SERVICES } from '../../../src/common/constants' ;
1616import { Config , configs , configsRefs } from '../../../src/configs/models/config' ;
17+ import { SchemaNotFoundError } from '../../../src/schemas/models/errors' ;
1718import { ConfigRequestSender } from './helpers/requestSender' ;
1819import { configsMockData , refs , schemaWithRef , simpleSchema , primitiveRefSchema , primitiveSchema } from './helpers/data' ;
1920
@@ -28,7 +29,7 @@ async function getSchemaMock(id: string): Promise<JSONSchema> {
2829 case primitiveRefSchema . $id :
2930 return Promise . resolve ( primitiveRefSchema ) ;
3031 default :
31- throw new Error ( 'Schema not found' ) ;
32+ throw new SchemaNotFoundError ( 'Schema not found' ) ;
3233 }
3334}
3435
@@ -536,6 +537,21 @@ describe('config', function () {
536537 expect ( response ) . toSatisfyApiSpec ( ) ;
537538 } ) ;
538539
540+ it ( 'should return 400 if the schemaId of the config does not exist' , async function ( ) {
541+ const response = await requestSender . postConfig ( {
542+ configName : 'config-not-exists' ,
543+ schemaId : 'https://mapcolonies.com/not-exists/v1' ,
544+ version : 1 ,
545+ config : {
546+ manager : 'null' ,
547+ role : 'unknown' ,
548+ } ,
549+ } ) ;
550+
551+ expect ( response . status ) . toBe ( httpStatusCodes . BAD_REQUEST ) ;
552+ expect ( response ) . toSatisfyApiSpec ( ) ;
553+ } ) ;
554+
539555 it ( 'should return 409 status code when trying to post a new version of a config that does not exists' , async function ( ) {
540556 const response = await requestSender . postConfig ( {
541557 configName : 'not-exists' ,
0 commit comments