@@ -275,7 +275,7 @@ describe('RoutingConfigClient', () => {
275275 } ;
276276
277277 mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
278- data : { features : { } , campaignIds : [ campaignId ] } ,
278+ data : { features : { routing : true } , campaignIds : [ campaignId ] } ,
279279 } ) ;
280280
281281 mocks . routingConfigRepository . create . mockResolvedValueOnce ( {
@@ -356,7 +356,7 @@ describe('RoutingConfigClient', () => {
356356 } ;
357357
358358 mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
359- data : { features : { } , campaignIds : [ 'campaign' ] } ,
359+ data : { features : { routing : true } , campaignIds : [ 'campaign' ] } ,
360360 } ) ;
361361
362362 mocks . routingConfigRepository . create . mockResolvedValueOnce ( {
@@ -420,6 +420,41 @@ describe('RoutingConfigClient', () => {
420420 } ) ;
421421 } ) ;
422422
423+ test ( 'returns failure if routing feature is disabled for the client' , async ( ) => {
424+ const { client, mocks } = setup ( ) ;
425+
426+ const input : CreateUpdateRoutingConfig = {
427+ name : 'rc' ,
428+ campaignId : 'campaign' ,
429+ cascade : [
430+ {
431+ cascadeGroups : [ 'standard' ] ,
432+ channel : 'SMS' ,
433+ channelType : 'primary' ,
434+ defaultTemplateId : 'sms' ,
435+ } ,
436+ ] ,
437+ cascadeGroupOverrides : [ { name : 'standard' } ] ,
438+ } ;
439+
440+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
441+ data : { features : { routing : false } , campaignIds : [ 'campaign' ] } ,
442+ } ) ;
443+
444+ const result = await client . createRoutingConfig ( input , user ) ;
445+
446+ expect ( mocks . routingConfigRepository . create ) . not . toHaveBeenCalled ( ) ;
447+
448+ expect ( result ) . toEqual ( {
449+ error : {
450+ errorMeta : {
451+ code : 400 ,
452+ description : 'Routing feature is disabled' ,
453+ } ,
454+ } ,
455+ } ) ;
456+ } ) ;
457+
423458 test ( 'returns failure if campaignId is not allowed for the client' , async ( ) => {
424459 const { client, mocks } = setup ( ) ;
425460
@@ -438,7 +473,10 @@ describe('RoutingConfigClient', () => {
438473 } ;
439474
440475 mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
441- data : { features : { } , campaignIds : [ 'another campaign' ] } ,
476+ data : {
477+ features : { routing : true } ,
478+ campaignIds : [ 'another campaign' ] ,
479+ } ,
442480 } ) ;
443481
444482 const result = await client . createRoutingConfig ( input , user ) ;
@@ -460,6 +498,10 @@ describe('RoutingConfigClient', () => {
460498 test ( 'returns completed routing config' , async ( ) => {
461499 const { client, mocks } = setup ( ) ;
462500
501+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
502+ data : { features : { routing : true } } ,
503+ } ) ;
504+
463505 const id = '2cb1c52d-befa-42f4-8628-06cfe63aa64d' ;
464506
465507 const completed : RoutingConfig = {
@@ -482,12 +524,37 @@ describe('RoutingConfigClient', () => {
482524 data : completed ,
483525 } ) ;
484526 } ) ;
527+
528+ test ( 'returns failure if routing feature is disabled for the client' , async ( ) => {
529+ const { client, mocks } = setup ( ) ;
530+
531+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
532+ data : { features : { routing : false } } ,
533+ } ) ;
534+
535+ const result = await client . submitRoutingConfig ( 'some-id' , user ) ;
536+
537+ expect ( mocks . routingConfigRepository . submit ) . not . toHaveBeenCalled ( ) ;
538+
539+ expect ( result ) . toEqual ( {
540+ error : {
541+ errorMeta : {
542+ code : 400 ,
543+ description : 'Routing feature is disabled' ,
544+ } ,
545+ } ,
546+ } ) ;
547+ } ) ;
485548 } ) ;
486549
487550 describe ( 'deleteRoutingConfig' , ( ) => {
488551 test ( 'returns undefined after deleting routing config' , async ( ) => {
489552 const { client, mocks } = setup ( ) ;
490553
554+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
555+ data : { features : { routing : true } } ,
556+ } ) ;
557+
491558 const id = '2cb1c52d-befa-42f4-8628-06cfe63aa64d' ;
492559
493560 const deleted : RoutingConfig = {
@@ -514,6 +581,10 @@ describe('RoutingConfigClient', () => {
514581 test ( 'returns error response from repository' , async ( ) => {
515582 const { client, mocks } = setup ( ) ;
516583
584+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
585+ data : { features : { routing : true } } ,
586+ } ) ;
587+
517588 const id = '2cb1c52d-befa-42f4-8628-06cfe63aa64d' ;
518589
519590 const errorResponse = {
@@ -531,6 +602,27 @@ describe('RoutingConfigClient', () => {
531602
532603 expect ( result ) . toEqual ( errorResponse ) ;
533604 } ) ;
605+
606+ test ( 'returns failure if routing feature is disabled for the client' , async ( ) => {
607+ const { client, mocks } = setup ( ) ;
608+
609+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
610+ data : { features : { routing : false } , campaignIds : [ 'campaign' ] } ,
611+ } ) ;
612+
613+ const result = await client . deleteRoutingConfig ( 'some-id' , user ) ;
614+
615+ expect ( mocks . routingConfigRepository . delete ) . not . toHaveBeenCalled ( ) ;
616+
617+ expect ( result ) . toEqual ( {
618+ error : {
619+ errorMeta : {
620+ code : 400 ,
621+ description : 'Routing feature is disabled' ,
622+ } ,
623+ } ,
624+ } ) ;
625+ } ) ;
534626 } ) ;
535627
536628 describe ( 'updateRoutingConfig' , ( ) => {
@@ -550,7 +642,10 @@ describe('RoutingConfigClient', () => {
550642 } ;
551643
552644 mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
553- data : { features : { } , campaignIds : [ routingConfig . campaignId ] } ,
645+ data : {
646+ features : { routing : true } ,
647+ campaignIds : [ routingConfig . campaignId ] ,
648+ } ,
554649 } ) ;
555650
556651 mocks . routingConfigRepository . update . mockResolvedValueOnce ( {
@@ -648,6 +743,41 @@ describe('RoutingConfigClient', () => {
648743 } ) ;
649744 } ) ;
650745
746+ test ( 'returns failure if routing feature is disabled for the client' , async ( ) => {
747+ const { client, mocks } = setup ( ) ;
748+
749+ const update : CreateUpdateRoutingConfig = {
750+ cascade : routingConfig . cascade ,
751+ cascadeGroupOverrides : routingConfig . cascadeGroupOverrides ,
752+ name : routingConfig . name ,
753+ campaignId : 'this campaign' ,
754+ } ;
755+
756+ mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
757+ data : {
758+ features : { routing : false } ,
759+ campaignIds : [ 'this campaign' ] ,
760+ } ,
761+ } ) ;
762+
763+ const result = await client . updateRoutingConfig (
764+ routingConfig . id ,
765+ update ,
766+ user
767+ ) ;
768+
769+ expect ( mocks . routingConfigRepository . update ) . not . toHaveBeenCalled ( ) ;
770+
771+ expect ( result ) . toEqual ( {
772+ error : {
773+ errorMeta : {
774+ code : 400 ,
775+ description : 'Routing feature is disabled' ,
776+ } ,
777+ } ,
778+ } ) ;
779+ } ) ;
780+
651781 test ( 'returns failure if campaignId is not allowed for the client' , async ( ) => {
652782 const { client, mocks } = setup ( ) ;
653783
@@ -659,7 +789,10 @@ describe('RoutingConfigClient', () => {
659789 } ;
660790
661791 mocks . clientConfigRepository . get . mockResolvedValueOnce ( {
662- data : { features : { } , campaignIds : [ 'another campaign' ] } ,
792+ data : {
793+ features : { routing : true } ,
794+ campaignIds : [ 'another campaign' ] ,
795+ } ,
663796 } ) ;
664797
665798 const result = await client . updateRoutingConfig (
0 commit comments