@@ -43,11 +43,16 @@ describe('CaseEditSubmitComponent', () => {
4343 const FORM_GROUP = new FormGroup ( {
4444 'data' : new FormGroup ( { 'PersonLastName' : new FormControl ( 'Khaleesi' ) } )
4545 } ) ;
46+ const COMPLEX_ELEMENT_HIDDEN = new FormGroup ( {
47+ 'childField1' : new FormControl ( 'Child field of complex type' )
48+ } ) ;
49+ COMPLEX_ELEMENT_HIDDEN . disable ( ) ;
4650 const FORM_GROUP_WITH_HIDDEN_FIELDS = new FormGroup ( {
4751 'data' : new FormGroup ( {
4852 'field1' : new FormControl ( { value : 'Hidden value to be retained' , disabled : true } ) ,
4953 'field2' : new FormControl ( { value : 'Hidden value not to be retained' , disabled : true } ) ,
50- 'field3' : new FormControl ( 'Hide both' )
54+ 'field3' : new FormControl ( 'Hide all' ) ,
55+ 'complexField1' : COMPLEX_ELEMENT_HIDDEN
5156 } )
5257 } ) ;
5358 let caseEditComponent : any ;
@@ -58,10 +63,12 @@ describe('CaseEditSubmitComponent', () => {
5863 let profileNotifier ;
5964 let profileNotifierSpy ;
6065 let casesReferencePipe : any ;
61- let caseField1 : CaseField = aCaseField ( 'field1' , 'field1' , 'Text' , 'OPTIONAL' , 3 ) ;
62- let caseField2 : CaseField = aCaseField ( 'field2' , 'field2' , 'Text' , 'OPTIONAL' , 2 ) ;
63- let caseField3 : CaseField = aCaseField ( 'field3' , 'field3' , 'Text' , 'OPTIONAL' , 1 ) ;
64- let caseFieldRetainHiddenValue : CaseField = aCaseField ( 'field1' , 'field1' , 'Text' , 'OPTIONAL' , 3 , null , true ) ;
66+ const caseField1 : CaseField = aCaseField ( 'field1' , 'field1' , 'Text' , 'OPTIONAL' , 4 ) ;
67+ const caseField2 : CaseField = aCaseField ( 'field2' , 'field2' , 'Text' , 'OPTIONAL' , 3 ) ;
68+ const caseField3 : CaseField = aCaseField ( 'field3' , 'field3' , 'Text' , 'OPTIONAL' , 2 ) ;
69+ const complexSubField : CaseField = aCaseField ( 'childField1' , 'childField1' , 'Text' , 'OPTIONAL' , 1 ) ;
70+ const complexCaseField : CaseField = aCaseField ( 'complexField1' , 'complexField1' , 'Complex' , 'OPTIONAL' , 1 , [ complexSubField ] ) ;
71+ const caseFieldRetainHiddenValue : CaseField = aCaseField ( 'field1' , 'field1' , 'Text' , 'OPTIONAL' , 4 , null , true ) ;
6572 const $EVENT_NOTES = By . css ( '#fieldset-event' ) ;
6673 let cancelled : any ;
6774 let snapshot : any ;
@@ -341,16 +348,16 @@ describe('CaseEditSubmitComponent', () => {
341348 } ) ;
342349
343350 it ( 'should sort case fields with show_summary_content_option' , ( ) => {
344- expect ( comp . eventTrigger . case_fields [ 0 ] . show_summary_content_option ) . toBe ( 3 ) ;
345- expect ( comp . eventTrigger . case_fields [ 1 ] . show_summary_content_option ) . toBe ( 2 ) ;
346- expect ( comp . eventTrigger . case_fields [ 2 ] . show_summary_content_option ) . toBe ( 1 ) ;
351+ expect ( comp . eventTrigger . case_fields [ 0 ] . show_summary_content_option ) . toBe ( 4 ) ;
352+ expect ( comp . eventTrigger . case_fields [ 1 ] . show_summary_content_option ) . toBe ( 3 ) ;
353+ expect ( comp . eventTrigger . case_fields [ 2 ] . show_summary_content_option ) . toBe ( 2 ) ;
347354 expect ( orderService . sort ) . toHaveBeenCalledWith (
348355 comp . eventTrigger . case_fields ,
349356 CaseEditSubmitComponent . SHOW_SUMMARY_CONTENT_COMPARE_FUNCTION ) ;
350357 expect ( comp . showSummaryFields . length ) . toBe ( 3 ) ;
351- expect ( comp . showSummaryFields [ 0 ] . show_summary_content_option ) . toBe ( 1 ) ;
352- expect ( comp . showSummaryFields [ 1 ] . show_summary_content_option ) . toBe ( 2 ) ;
353- expect ( comp . showSummaryFields [ 2 ] . show_summary_content_option ) . toBe ( 3 ) ;
358+ expect ( comp . showSummaryFields [ 0 ] . show_summary_content_option ) . toBe ( 2 ) ;
359+ expect ( comp . showSummaryFields [ 1 ] . show_summary_content_option ) . toBe ( 3 ) ;
360+ expect ( comp . showSummaryFields [ 2 ] . show_summary_content_option ) . toBe ( 4 ) ;
354361 } ) ;
355362
356363 it ( 'should return "Cancel" text label for cancel button when save and resume disabled' , ( ) => {
@@ -709,12 +716,14 @@ describe('CaseEditSubmitComponent', () => {
709716 aWizardPage ( 'page1' , 'Page 1' , 1 ) ,
710717 ] ;
711718 const firstPage = pages [ 0 ] ;
712- caseFieldRetainHiddenValue . show_condition = 'field3!="Hide both"' ;
713- caseField2 . show_condition = 'field3!="Hide both"' ;
719+ caseFieldRetainHiddenValue . show_condition = 'field3!="Hide all"' ;
720+ caseField2 . show_condition = 'field3!="Hide all"' ;
721+ complexCaseField . show_condition = 'field3!="Hide all"' ;
714722 const WP_FIELD_1 : WizardPageField = { case_field_id : caseFieldRetainHiddenValue . id } ;
715723 const WP_FIELD_2 : WizardPageField = { case_field_id : caseField2 . id } ;
716724 const WP_FIELD_3 : WizardPageField = { case_field_id : caseField3 . id } ;
717- firstPage . wizard_page_fields = [ WP_FIELD_1 , WP_FIELD_2 , WP_FIELD_3 ] ;
725+ const WP_FIELD_4 : WizardPageField = { case_field_id : complexCaseField . id } ;
726+ firstPage . wizard_page_fields = [ WP_FIELD_1 , WP_FIELD_2 , WP_FIELD_3 , WP_FIELD_4 ] ;
718727 wizard = new Wizard ( pages ) ;
719728 const queryParamMapNoProfile = createSpyObj ( 'queryParamMap' , [ 'get' ] ) ;
720729 const snapshotNoProfile = {
@@ -749,15 +758,18 @@ describe('CaseEditSubmitComponent', () => {
749758 beforeEach ( async ( ( ) => {
750759 // Need to set the page case_fields here because, for some reason, if set initially then these get overridden
751760 // by some unknown default!
752- firstPage . case_fields = [ caseFieldRetainHiddenValue , caseField2 , caseField3 ] ;
761+ firstPage . case_fields = [ caseFieldRetainHiddenValue , caseField2 , caseField3 , complexCaseField ] ;
753762 orderService = new OrderService ( ) ;
754763 casesReferencePipe = createSpyObj < CaseReferencePipe > ( 'caseReference' , [ 'transform' ] ) ;
755764 cancelled = createSpyObj ( 'cancelled' , [ 'emit' ] )
756765 caseEditComponent = {
757766 'form' : FORM_GROUP_WITH_HIDDEN_FIELDS ,
758767 'fieldsPurger' : new FieldsPurger ( fieldsUtils ) ,
759768 'data' : '' ,
760- 'eventTrigger' : { 'case_fields' : [ caseFieldRetainHiddenValue , caseField2 , caseField3 ] , 'can_save_draft' : true } ,
769+ 'eventTrigger' : {
770+ 'case_fields' : [ caseFieldRetainHiddenValue , caseField2 , caseField3 , complexCaseField ] ,
771+ 'can_save_draft' : true
772+ } ,
761773 'wizard' : wizard ,
762774 'hasPrevious' : ( ) => true ,
763775 'getPage' : ( ) => firstPage ,
@@ -812,7 +824,7 @@ describe('CaseEditSubmitComponent', () => {
812824 fixture . detectChanges ( ) ;
813825 } ) ;
814826
815- it ( 'should submit CaseEventData with null for any hidden fields whose values are not to be retained' , ( ) => {
827+ it ( 'should submit CaseEventData with null for any hidden fields (excluding Complex types) whose values are not to be retained' , ( ) => {
816828 // Trigger the clearing of hidden fields by invoking next()
817829 caseEditComponent . next ( ) ;
818830
@@ -821,7 +833,7 @@ describe('CaseEditSubmitComponent', () => {
821833 expect ( caseEditComponent . submit ) . toHaveBeenCalledWith ( {
822834 data : {
823835 field2 : null ,
824- field3 : 'Hide both '
836+ field3 : 'Hide all '
825837 } ,
826838 event_token : undefined ,
827839 ignore_warning : false
0 commit comments