@@ -3,7 +3,7 @@ import { html, css, nothing, type TemplateResult } from 'lit'
33import { customElement } from 'lit/decorators.js'
44import { consume } from '@lit/context'
55import type { TestStats , SuiteStats } from '@wdio/reporter'
6-
6+ import { repeat } from 'lit/directives/repeat.js'
77import { TestState } from './test-suite.js'
88import { suiteContext } from '../../controller/DataManager.js'
99
@@ -20,6 +20,7 @@ import type { DevtoolsSidebarFilter } from './filter.js'
2020const EXPLORER = 'wdio-devtools-sidebar-explorer'
2121
2222interface TestEntry {
23+ uid : string
2324 state ?: string
2425 label : string
2526 children : TestEntry [ ]
@@ -53,10 +54,16 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
5354 return html `
5455 < wdio-test-entry state ="${ entry . state as any } ">
5556 < label slot ="label "> ${ entry . label } </ label >
56- ${ entry . children && entry . children . length ?
57- html `
58- < wdio-test-suite slot ="children "> ${ entry . children . map ( this . #renderEntry. bind ( this ) ) } </ wdio-test-suite >
59- `
57+ ${ entry . children && entry . children . length
58+ ? html `
59+ < wdio-test-suite slot ="children ">
60+ ${ repeat (
61+ entry . children ,
62+ child => child . uid ,
63+ child => this . #renderEntry( child )
64+ ) }
65+ </ wdio-test-suite >
66+ `
6067 : nothing
6168 }
6269 </ wdio-test-entry >
@@ -88,6 +95,7 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
8895 if ( 'tests' in entry ) {
8996 const entries = [ ...entry . tests , ...entry . suites ]
9097 return {
98+ uid : entry . uid ,
9199 label : entry . title ,
92100 state : entry . tests . some ( ( t ) => ! t . end )
93101 ? TestState . RUNNING
@@ -100,6 +108,7 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
100108 }
101109 }
102110 return {
111+ uid : entry . uid ,
103112 label : entry . title ,
104113 state : ! entry . end
105114 ? TestState . RUNNING
@@ -114,7 +123,18 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
114123 if ( ! this . suites ) {
115124 return
116125 }
117- const suites = Object . values ( this . suites [ 0 ] )
126+
127+ // ✅ Only root suites (no parent = true top-level suite)
128+ const rootSuites = this . suites
129+ . flatMap ( s => Object . values ( s ) )
130+ . filter ( suite => ! suite . parent )
131+
132+ // Deduplicate by uid (in case some frameworks still push duplicates)
133+ const uniqueSuites = Array . from (
134+ new Map ( rootSuites . map ( suite => [ suite . uid , suite ] ) ) . values ( )
135+ )
136+
137+ const suites = uniqueSuites
118138 . map ( this . #getTestEntry. bind ( this ) )
119139 . filter ( this . #filterEntry. bind ( this ) )
120140
@@ -132,7 +152,11 @@ export class DevtoolsSidebarExplorer extends CollapseableEntry {
132152 </ header >
133153 < wdio-test-suite >
134154 ${ suites . length
135- ? suites . map ( this . #renderEntry. bind ( this ) )
155+ ? repeat (
156+ suites ,
157+ suite => suite . uid ,
158+ suite => this . #renderEntry( suite )
159+ )
136160 : html `< p class ="text-disabledForeground text-sm px-4 py-2 "> No tests found</ p > `
137161 }
138162 </ wdio-test-suite >
0 commit comments