@@ -337,6 +337,59 @@ module('Component Tab', function (hooks) {
337337 ) ;
338338 } ) ;
339339
340+ test ( 'it should only show parents and children of selected item in focus mode' , async function ( assert ) {
341+ await visit ( '/component-tree' ) ;
342+
343+ function findTreeItem ( children , id ) {
344+ for ( const child of children ) {
345+ if ( child . id . includes ( `render-node:${ id } ` ) ) {
346+ return child ;
347+ }
348+ const found = findTreeItem ( child . children , id ) ;
349+ if ( found ) {
350+ return found ;
351+ }
352+ }
353+ }
354+
355+ function getCustomRenderTree ( ) {
356+ const tree = getRenderTree ( { withChildren : true } ) ;
357+ const subtask = findTreeItem ( tree , 6 ) ;
358+ const todo = findTreeItem ( tree , 3 ) ;
359+ subtask . children . push ( Component ( { id : 7 , name : 'sub-task-child' } ) ) ;
360+ subtask . children . push ( Component ( { id : 8 , name : 'sub-task-child' } ) ) ;
361+ todo . children . push ( Component ( { id : 9 , name : 'todo-list-2' } ) ) ;
362+ return tree ;
363+ }
364+
365+ await sendMessage ( {
366+ type : 'view:renderTree' ,
367+ tree : getCustomRenderTree ( ) ,
368+ } ) ;
369+
370+ await rerender ( ) ;
371+
372+ let treeNodes = findAll ( '.component-tree-item' ) ;
373+ assert . strictEqual ( treeNodes . length , 5 , 'expected all tree nodes' ) ;
374+
375+ let expanders = findAll ( '.component-tree-item-expand' ) ;
376+ let expanderEl = expanders [ expanders . length - 1 ] ;
377+ await click ( expanderEl ) ;
378+
379+ treeNodes = findAll ( '.component-tree-item' ) ;
380+ const subTask = treeNodes
381+ . filter ( ( t ) => t . textContent . toLowerCase ( ) . includes ( 'subtask' ) )
382+ . at ( - 1 ) ;
383+
384+ respondWith ( 'view:showInspection' , false , { count : 1 } ) ;
385+ await click ( subTask ) ;
386+
387+ await click ( '[data-test-toggle-focus]' ) ;
388+
389+ treeNodes = findAll ( '.component-tree-item' ) ;
390+ assert . strictEqual ( treeNodes . length , 6 , 'expected all tree nodes' ) ;
391+ } ) ;
392+
340393 test ( 'It should clear the search filter when the clear button is clicked' , async function ( assert ) {
341394 await visit ( '/component-tree' ) ;
342395
0 commit comments