@@ -449,6 +449,28 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
449449 expect ( childGrid . data ) . toBe ( newData2 [ 0 ] . childData ) ;
450450 } ) ;
451451
452+ it ( 'should update already created child grid with new records added to the root data' , ( ) => {
453+ let row = hierarchicalGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
454+ UIInteractions . simulateClickAndSelectEvent ( row . expander ) ;
455+ fixture . detectChanges ( ) ;
456+
457+ let childGrids = fixture . debugElement . queryAll ( By . css ( 'igx-child-grid-row' ) ) ;
458+ let childGrid = childGrids [ 0 ] . query ( By . css ( 'igx-hierarchical-grid' ) ) . componentInstance ;
459+
460+ fixture . componentInstance . data [ 0 ] . childData = [ ...hierarchicalGrid . data [ 0 ] . childData ?? [ ] , { ID : 10 , ProductName : 'New child' } ] ;
461+ fixture . componentInstance . data = [ ...fixture . componentInstance . data ] ;
462+ fixture . detectChanges ( ) ;
463+
464+ childGrids = fixture . debugElement . queryAll ( By . css ( 'igx-child-grid-row' ) ) ;
465+ childGrid = childGrids [ 0 ] . query ( By . css ( 'igx-hierarchical-grid' ) ) . componentInstance ;
466+
467+ const length = fixture . componentInstance . data [ 0 ] . childData . length ;
468+ const newRow = childGrid . gridAPI . get_row_by_index ( length - 1 ) as IgxHierarchicalRowComponent ;
469+
470+ expect ( newRow ) . not . toBeUndefined ( ) ;
471+ expect ( childGrid . data ) . toBe ( fixture . componentInstance . data [ 0 ] . childData ) ;
472+ } ) ;
473+
452474 it ( 'when child width is in percents its width should be update if parent width changes while parent row is collapsed. ' , async ( ) => {
453475 const row = hierarchicalGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
454476 UIInteractions . simulateClickAndSelectEvent ( row . expander ) ;
0 commit comments