@@ -2616,15 +2616,17 @@ describe('MappingActionService', () => {
26162616 } ) ;
26172617 } ) ;
26182618
2619- describe ( 'getAllowedActions() inner instructions on unselected wrapper fields' , ( ) => {
2620- const innerInstructionKinds = [
2619+ describe ( 'getAllowedActions() on unselected wrapper fields' , ( ) => {
2620+ const disallowedOnUnselectedWrapperKinds = [
26212621 MappingActionKind . InnerForEach ,
26222622 MappingActionKind . InnerForEachGroup ,
26232623 MappingActionKind . InnerChoose ,
26242624 MappingActionKind . InnerIf ,
2625+ MappingActionKind . ValueSelector ,
2626+ MappingActionKind . CopyOfSelector ,
26252627 ] ;
26262628
2627- it ( 'should disallow inner instructions on unselected choice field' , ( ) => {
2629+ it ( 'should disallow actions on unselected choice field' , ( ) => {
26282630 const document = TestUtil . createTargetOrderDoc ( ) ;
26292631 const mappingTree = new MappingTree (
26302632 document . documentType ,
@@ -2644,12 +2646,12 @@ describe('MappingActionService', () => {
26442646
26452647 const unselectedNode = new TargetChoiceFieldNodeData ( docNode , choiceField ) ;
26462648 const allowed = MappingActionRegistryService . getAllowedActions ( unselectedNode ) ;
2647- for ( const kind of innerInstructionKinds ) {
2649+ for ( const kind of disallowedOnUnselectedWrapperKinds ) {
26482650 expect ( allowed ) . not . toContain ( kind ) ;
26492651 }
26502652 } ) ;
26512653
2652- it ( 'should allow inner instructions on selected choice field' , ( ) => {
2654+ it ( 'should allow actions on selected choice field' , ( ) => {
26532655 const document = TestUtil . createTargetOrderDoc ( ) ;
26542656 const mappingTree = new MappingTree (
26552657 document . documentType ,
@@ -2670,12 +2672,12 @@ describe('MappingActionService', () => {
26702672 const selectedNode = new TargetChoiceFieldNodeData ( docNode , memberA ) ;
26712673 selectedNode . choiceField = choiceField ;
26722674 const allowed = MappingActionRegistryService . getAllowedActions ( selectedNode ) ;
2673- for ( const kind of innerInstructionKinds ) {
2675+ for ( const kind of disallowedOnUnselectedWrapperKinds ) {
26742676 expect ( allowed ) . toContain ( kind ) ;
26752677 }
26762678 } ) ;
26772679
2678- it ( 'should disallow inner instructions on unsubstituted abstract field' , ( ) => {
2680+ it ( 'should disallow actions on unsubstituted abstract field' , ( ) => {
26792681 const document = TestUtil . createTargetOrderDoc ( ) ;
26802682 const mappingTree = new MappingTree (
26812683 document . documentType ,
@@ -2695,12 +2697,12 @@ describe('MappingActionService', () => {
26952697
26962698 const unselectedNode = new TargetAbstractFieldNodeData ( docNode , abstractField ) ;
26972699 const allowed = MappingActionRegistryService . getAllowedActions ( unselectedNode ) ;
2698- for ( const kind of innerInstructionKinds ) {
2700+ for ( const kind of disallowedOnUnselectedWrapperKinds ) {
26992701 expect ( allowed ) . not . toContain ( kind ) ;
27002702 }
27012703 } ) ;
27022704
2703- it ( 'should allow inner instructions on substituted abstract field' , ( ) => {
2705+ it ( 'should allow actions on substituted abstract field' , ( ) => {
27042706 const document = TestUtil . createTargetOrderDoc ( ) ;
27052707 const mappingTree = new MappingTree (
27062708 document . documentType ,
@@ -2721,10 +2723,54 @@ describe('MappingActionService', () => {
27212723 const selectedNode = new TargetAbstractFieldNodeData ( docNode , candidate ) ;
27222724 selectedNode . abstractField = abstractField ;
27232725 const allowed = MappingActionRegistryService . getAllowedActions ( selectedNode ) ;
2724- for ( const kind of innerInstructionKinds ) {
2726+ for ( const kind of disallowedOnUnselectedWrapperKinds ) {
27252727 expect ( allowed ) . toContain ( kind ) ;
27262728 }
27272729 } ) ;
2730+
2731+ it ( 'should disallow Variable on unselected choice field' , ( ) => {
2732+ const document = TestUtil . createTargetOrderDoc ( ) ;
2733+ const mappingTree = new MappingTree (
2734+ document . documentType ,
2735+ document . documentId ,
2736+ DocumentDefinitionType . XML_SCHEMA ,
2737+ ) ;
2738+ const docNode = new TargetDocumentNodeData ( document , mappingTree ) ;
2739+ const parentField = document . fields [ 0 ] ;
2740+
2741+ const choiceField = new XmlSchemaField ( parentField , 'testChoice' , false ) ;
2742+ choiceField . type = Types . Container ;
2743+ choiceField . wrapperKind = 'choice' ;
2744+ const memberA = new XmlSchemaField ( choiceField , 'memberA' , false ) ;
2745+ memberA . type = Types . String ;
2746+ choiceField . fields = [ memberA ] ;
2747+ parentField . fields . push ( choiceField ) ;
2748+
2749+ const unselectedNode = new TargetChoiceFieldNodeData ( docNode , choiceField ) ;
2750+ expect ( MappingActionRegistryService . getAllowedActions ( unselectedNode ) ) . not . toContain ( MappingActionKind . Variable ) ;
2751+ } ) ;
2752+
2753+ it ( 'should disallow Variable on unsubstituted abstract field' , ( ) => {
2754+ const document = TestUtil . createTargetOrderDoc ( ) ;
2755+ const mappingTree = new MappingTree (
2756+ document . documentType ,
2757+ document . documentId ,
2758+ DocumentDefinitionType . XML_SCHEMA ,
2759+ ) ;
2760+ const docNode = new TargetDocumentNodeData ( document , mappingTree ) ;
2761+ const parentField = document . fields [ 0 ] ;
2762+
2763+ const abstractField = new XmlSchemaField ( parentField , 'testAbstract' , false ) ;
2764+ abstractField . type = Types . Container ;
2765+ abstractField . wrapperKind = 'abstract' ;
2766+ const candidate = new XmlSchemaField ( abstractField , 'ConcreteType' , false ) ;
2767+ candidate . type = Types . String ;
2768+ abstractField . fields = [ candidate ] ;
2769+ parentField . fields . push ( abstractField ) ;
2770+
2771+ const unselectedNode = new TargetAbstractFieldNodeData ( docNode , abstractField ) ;
2772+ expect ( MappingActionRegistryService . getAllowedActions ( unselectedNode ) ) . not . toContain ( MappingActionKind . Variable ) ;
2773+ } ) ;
27282774 } ) ;
27292775
27302776 describe ( 'UnknownMappingItem visibility' , ( ) => {
0 commit comments