@@ -419,10 +419,14 @@ describe('deploymentErrorsToCustomSections', () => {
419419 ]
420420
421421 // When
422- const customSections = deploymentErrorsToCustomSections ( errors , {
423- 'amortizable-marketplace-ext' : '123' ,
424- 'amortizable-marketplace-ext-2' : '456' ,
425- } )
422+ const customSections = deploymentErrorsToCustomSections (
423+ errors ,
424+ {
425+ 'amortizable-marketplace-ext' : '123' ,
426+ 'amortizable-marketplace-ext-2' : '456' ,
427+ } ,
428+ [ ] ,
429+ )
426430
427431 // Then
428432 expect ( customSections ) . toEqual ( [
@@ -480,10 +484,14 @@ describe('deploymentErrorsToCustomSections', () => {
480484 ]
481485
482486 // When
483- const customSections = deploymentErrorsToCustomSections ( errors , {
484- 'amortizable-marketplace-ext' : '123' ,
485- 'amortizable-marketplace-ext-2' : '456' ,
486- } )
487+ const customSections = deploymentErrorsToCustomSections (
488+ errors ,
489+ {
490+ 'amortizable-marketplace-ext' : '123' ,
491+ 'amortizable-marketplace-ext-2' : '456' ,
492+ } ,
493+ [ ] ,
494+ )
487495
488496 // Then
489497 expect ( customSections ) . toEqual ( [
@@ -511,10 +519,14 @@ describe('deploymentErrorsToCustomSections', () => {
511519 ]
512520
513521 // When
514- const customSections = deploymentErrorsToCustomSections ( errors , {
515- 'amortizable-marketplace-ext' : '123' ,
516- 'amortizable-marketplace-ext-2' : '456' ,
517- } )
522+ const customSections = deploymentErrorsToCustomSections (
523+ errors ,
524+ {
525+ 'amortizable-marketplace-ext' : '123' ,
526+ 'amortizable-marketplace-ext-2' : '456' ,
527+ } ,
528+ [ ] ,
529+ )
518530
519531 // Then
520532 expect ( customSections ) . toEqual ( [
@@ -546,6 +558,7 @@ describe('deploymentErrorsToCustomSections', () => {
546558 'amortizable-marketplace-ext' : '123' ,
547559 'amortizable-marketplace-ext-2' : '456' ,
548560 } ,
561+ [ ] ,
549562 {
550563 version : 'already-taken-version' ,
551564 } ,
@@ -581,9 +594,13 @@ describe('deploymentErrorsToCustomSections', () => {
581594 ]
582595
583596 // When
584- const customSections = deploymentErrorsToCustomSections ( errors , {
585- b05ef3d6a573863fa3b21fae7689f1 : '686809612289' ,
586- } )
597+ const customSections = deploymentErrorsToCustomSections (
598+ errors ,
599+ {
600+ b05ef3d6a573863fa3b21fae7689f1 : '686809612289' ,
601+ } ,
602+ [ ] ,
603+ )
587604
588605 // Then
589606 expect ( customSections ) . toEqual ( [
@@ -667,13 +684,17 @@ describe('deploymentErrorsToCustomSections', () => {
667684 ]
668685
669686 // When
670- const customSections = deploymentErrorsToCustomSections ( errors as AppDeploySchema [ 'appDeploy' ] [ 'userErrors' ] , {
671- 'webhook-subscription-1' : '1' ,
672- 'webhook-subscription-2' : '2' ,
673- 'webhook-subscription-3' : '3' ,
674- 'webhook-subscription-4' : '4' ,
675- 'webhook-subscription-5' : '5' ,
676- } )
687+ const customSections = deploymentErrorsToCustomSections (
688+ errors as AppDeploySchema [ 'appDeploy' ] [ 'userErrors' ] ,
689+ {
690+ 'webhook-subscription-1' : '1' ,
691+ 'webhook-subscription-2' : '2' ,
692+ 'webhook-subscription-3' : '3' ,
693+ 'webhook-subscription-4' : '4' ,
694+ 'webhook-subscription-5' : '5' ,
695+ } ,
696+ [ ] ,
697+ )
677698
678699 // Then
679700 expect ( customSections ) . toEqual ( [
@@ -695,4 +716,102 @@ describe('deploymentErrorsToCustomSections', () => {
695716 } ,
696717 ] )
697718 } )
719+
720+ test ( 'returns sections for app management validation errors with found appModules' , ( ) => {
721+ // Given
722+ const errors = [
723+ {
724+ field : [ 'supported_buyer_contexts' , 'currency' ] ,
725+ message : 'must be a valid uppercase alpha-3 ISO 4217 value, invalid value: CADs' ,
726+ category : 'invalid' ,
727+ on : [
728+ {
729+ type : 'app_module' ,
730+ app_module_uuid : '0198a414-9812-7907-820c-773de19dede3' ,
731+ version_uuid : '0198a7a2-81fd-733d-b63c-1afe052b7fb3' ,
732+ specification_identifier : 'payments_extension' ,
733+ user_identifier : 'my-payment-extension-uid' ,
734+ } ,
735+ ] ,
736+ details : [ ] ,
737+ } ,
738+ {
739+ field : [ 'targeting' , 'target' ] ,
740+ message : 'is required' ,
741+ category : 'invalid' ,
742+ on : [
743+ {
744+ type : 'app_module' ,
745+ user_identifier : 'my-discount-extension-uid' ,
746+ } ,
747+ ] ,
748+ details : [ ] ,
749+ } ,
750+ {
751+ field : [ 'name' ] ,
752+ message : 'is too long' ,
753+ category : 'invalid' ,
754+ on : [
755+ {
756+ type : 'app_module' ,
757+ user_identifier : 'my-payment-extension-uid' ,
758+ } ,
759+ ] ,
760+ details : [ ] ,
761+ } ,
762+ ]
763+
764+ const appModules = [
765+ {
766+ uid : 'my-payment-extension-uid' ,
767+ handle : 'my-payment-extension' ,
768+ config : '{}' ,
769+ context : '' ,
770+ specificationIdentifier : 'payments_extension' ,
771+ } ,
772+ {
773+ uid : 'my-discount-extension-uid' ,
774+ handle : 'my-discount-function' ,
775+ config : '{}' ,
776+ context : '' ,
777+ specificationIdentifier : 'discounts_extension' ,
778+ } ,
779+ ]
780+
781+ // When
782+ const customSections = deploymentErrorsToCustomSections (
783+ errors as any as AppDeploySchema [ 'appDeploy' ] [ 'userErrors' ] ,
784+ { } ,
785+ appModules ,
786+ )
787+
788+ // Then
789+ expect ( customSections ) . toEqual ( [
790+ {
791+ title : 'my-payment-extension' ,
792+ body : [
793+ {
794+ list : {
795+ title : '\nValidation errors' ,
796+ items : [
797+ 'supported_buyer_contexts.currency: must be a valid uppercase alpha-3 ISO 4217 value, invalid value: CADs' ,
798+ 'name: is too long' ,
799+ ] ,
800+ } ,
801+ } ,
802+ ] ,
803+ } ,
804+ {
805+ title : 'my-discount-function' ,
806+ body : [
807+ {
808+ list : {
809+ title : '\nValidation errors' ,
810+ items : [ 'targeting.target: is required' ] ,
811+ } ,
812+ } ,
813+ ] ,
814+ } ,
815+ ] )
816+ } )
698817} )
0 commit comments