@@ -2,7 +2,7 @@ import { Element } from '@core/element'
22import  {  html ,  css ,  nothing ,  type  TemplateResult  }  from  'lit' 
33import  {  customElement  }  from  'lit/decorators.js' 
44import  {  consume  }  from  '@lit/context' 
5- import  {   type  SuiteStats  }  from  '@wdio/reporter' 
5+ import  type   {   TestStats ,  SuiteStats  }  from  '@wdio/reporter' 
66
77import  {  TestState  }  from  './test-suite.js' 
88import  {  suiteContext  }  from  '../../controller/DataManager.js' 
@@ -36,8 +36,8 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
3636    } 
3737  ` ] 
3838
39-   @consume ( {  context : suiteContext  } ) 
40-   suites : Record < string ,  SuiteStats >   =   { } 
39+   @consume ( {  context : suiteContext ,   subscribe :  true  } ) 
40+   suites : Record < string ,  SuiteStats > [ ]   |   undefined   =   undefined 
4141
4242  connectedCallback ( ) : void   { 
4343    super . connectedCallback ( ) 
@@ -84,31 +84,39 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
8484    ) 
8585  } 
8686
87-   render ( )  { 
88-     if  ( typeof  this . suites  !==  'object' )  { 
89-       return 
87+   #getTestEntry ( entry : TestStats  |  SuiteStats ) : TestEntry  { 
88+     if  ( 'tests'  in  entry )  { 
89+       const  entries  =  [ ...entry . tests ,  ...entry . suites ] 
90+       return  { 
91+         label : entry . title , 
92+         state : entry . tests . some ( ( t )  =>  ! t . end ) 
93+           ? TestState . RUNNING 
94+           : entry . tests . find ( ( t )  =>  t . state  ===  'failed' ) 
95+             ? TestState . FAILED 
96+             : TestState . PASSED , 
97+         children : Object . values ( entries ) 
98+           . map ( this . #getTestEntry. bind ( this ) ) 
99+           . filter ( this . #filterEntry. bind ( this ) ) 
100+       } 
90101    } 
91-     const  suites  =  Object . values ( this . suites [ 0 ] ) . map ( ( suite : SuiteStats )  =>  { 
92-       const  state  =  ! suite . tests . find ( ( t )  =>  t . end ) 
102+     return  { 
103+       label : entry . title , 
104+       state : ! entry . end 
93105        ? TestState . RUNNING 
94-         : suite . tests . find ( ( t )   =>   t . state  ===  'failed' ) 
106+         : entry . state  ===  'failed' 
95107          ? TestState . FAILED 
96-           : TestState . PASSED 
108+           : TestState . PASSED , 
109+       children : [ ] 
110+     } 
111+   } 
97112
98-       return  { 
99-         label : suite . title , 
100-         state, 
101-         children : Object . values ( suite . tests ) . map ( ( test )  =>  ( { 
102-           label : test . title , 
103-           state : ! test . end 
104-             ? TestState . RUNNING 
105-             : test . state  ===  'failed' 
106-               ? TestState . FAILED 
107-               : TestState . PASSED , 
108-           children : [ ] 
109-         } ) ) . filter ( this . #filterEntry. bind ( this ) ) 
110-       } 
111-     } ) . filter ( this . #filterEntry. bind ( this ) ) 
113+   render ( )  { 
114+     if  ( ! this . suites )  { 
115+       return 
116+     } 
117+     const  suites  =  Object . values ( this . suites [ 0 ] ) 
118+       . map ( this . #getTestEntry. bind ( this ) ) 
119+       . filter ( this . #filterEntry. bind ( this ) ) 
112120
113121    return  html ` 
114122      < header  class ="pl-4 py-2 flex shadow-md pr-2 ">  
0 commit comments