@@ -9,6 +9,7 @@ import { IgxActionStripComponent } from '../../action-strip/public_api';
99import { IgxTreeGridRowComponent } from './tree-grid-row.component' ;
1010import { first } from 'rxjs/operators' ;
1111import { IRowDataCancelableEventArgs } from '../public_api' ;
12+ import { wait } from '../../test-utils/ui-interactions.spec' ;
1213
1314describe ( 'IgxTreeGrid - Add Row UI #tGrid' , ( ) => {
1415 configureTestSuite ( ) ;
@@ -216,5 +217,47 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
216217 const addedRow = treeGrid . getRowByKey ( newRowId ) ;
217218 expect ( addedRow . data [ treeGrid . foreignKey ] ) . toBe ( 2 ) ;
218219 } ) ;
220+
221+ it ( 'should collapse row when child row adding begins and it added row should go under correct parent.' , async ( ) => {
222+ treeGrid . data = [
223+ { ID : 1 , ParentID : - 1 , Name : 'Casey Houston' , JobTitle : 'Vice President' , Age : 32 } ,
224+ { ID : 2 , ParentID : 10 , Name : 'Gilberto Todd' , JobTitle : 'Director' , Age : 41 } ,
225+ { ID : 3 , ParentID : 10 , Name : 'Tanya Bennett' , JobTitle : 'Director' , Age : 29 } ,
226+ { ID : 4 , ParentID : 6 , Name : 'Jack Simon' , JobTitle : 'Software Developer' , Age : 33 } ,
227+ { ID : 6 , ParentID : - 1 , Name : 'Erma Walsh' , JobTitle : 'CEO' , Age : 52 } ,
228+ { ID : 7 , ParentID : 10 , Name : 'Debra Morton' , JobTitle : 'Associate Software Developer' , Age : 35 } ,
229+ { ID : 9 , ParentID : 10 , Name : 'Leslie Hansen' , JobTitle : 'Associate Software Developer' , Age : 44 } ,
230+ { ID : 10 , ParentID : - 1 , Name : 'Eduardo Ramirez' , JobTitle : 'Manager' , Age : 53 }
231+ ] ;
232+ fix . detectChanges ( ) ;
233+ treeGrid . collapseAll ( ) ;
234+ treeGrid . height = "350px" ;
235+ fix . detectChanges ( ) ;
236+ const parentRow1 = treeGrid . rowList . toArray ( ) [ 1 ] as IgxTreeGridRowComponent ;
237+ treeGrid . expandRow ( parentRow1 . key ) ;
238+ const parentRow2 = treeGrid . rowList . toArray ( ) [ 3 ] as IgxTreeGridRowComponent ;
239+ treeGrid . expandRow ( parentRow2 . key ) ;
240+ treeGrid . triggerPipes ( ) ;
241+ fix . detectChanges ( ) ;
242+
243+ // scroll bottom
244+ treeGrid . verticalScrollContainer . scrollTo ( treeGrid . dataView . length - 1 ) ;
245+ await wait ( 50 ) ;
246+ fix . detectChanges ( ) ;
247+ // start add row
248+ parentRow2 . beginAddChild ( ) ;
249+ fix . detectChanges ( ) ;
250+ // last row should be add row
251+ const addRow = treeGrid . gridAPI . get_row_by_index ( 4 ) ;
252+ expect ( addRow . addRowUI ) . toBeTrue ( ) ;
253+ endTransition ( ) ;
254+
255+ // end edit
256+ treeGrid . gridAPI . crudService . endEdit ( true ) ;
257+ fix . detectChanges ( ) ;
258+
259+ // row should be added under correct parent
260+ expect ( treeGrid . data [ treeGrid . data . length - 1 ] . ParentID ) . toBe ( 10 ) ;
261+ } ) ;
219262 } ) ;
220263} ) ;
0 commit comments