@@ -1612,13 +1612,21 @@ export async function findTreeNodeAtLevel(
16121612 if ( ! nodes ) {
16131613 const viewContent = await getViewContent ( "Testing" ) ;
16141614 const sections = await viewContent . getSections ( ) ;
1615- // Assume the top-level section is "Test Explorer"
1616- const testExplorerSection = sections . find (
1617- async ( section ) => ( await section . getTitle ( ) ) . trim ( ) === "Test Explorer"
1618- ) ;
1615+
1616+ // Manually find the "Test Explorer" section (instead of Promise.any)
1617+ let testExplorerSection : any | undefined ;
1618+ for ( const section of sections ) {
1619+ const title = await section . getTitle ( ) ;
1620+ if ( title . trim ( ) === "Test Explorer" ) {
1621+ testExplorerSection = section ;
1622+ break ;
1623+ }
1624+ }
1625+
16191626 if ( ! testExplorerSection ) {
16201627 throw new Error ( "Test Explorer section not found" ) ;
16211628 }
1629+
16221630 // For ViewSection, use getVisibleItems() to obtain its children.
16231631 nodes = await testExplorerSection . getVisibleItems ( ) ;
16241632 }
@@ -1631,20 +1639,21 @@ export async function findTreeNodeAtLevel(
16311639 return node ;
16321640 }
16331641 }
1634- return undefined ;
1635- }
1636-
1637- // Otherwise, iterate through nodes: expand each, then search its children.
1638- for ( const node of nodes ) {
1639- if ( ! ( await node . isExpanded ( ) ) ) {
1640- await node . expand ( ) ;
1641- }
1642- const children = await node . getChildren ( ) ;
1643- const found = await findTreeNodeAtLevel ( level - 1 , nodeName , children ) ;
1644- if ( found ) {
1645- return found ;
1642+ } else {
1643+ // Otherwise, iterate through nodes: expand each, then search its children.
1644+ for ( const node of nodes ) {
1645+ if ( ! ( await node . isExpanded ( ) ) ) {
1646+ await node . expand ( ) ;
1647+ }
1648+ const children = await node . getChildren ( ) ;
1649+ const found = await findTreeNodeAtLevel ( level - 1 , nodeName , children ) ;
1650+ if ( found ) {
1651+ return found ;
1652+ }
16461653 }
16471654 }
1655+
1656+ // Not found anywhere
16481657 return undefined ;
16491658}
16501659
0 commit comments