Skip to content

Commit f9a4b51

Browse files
committed
Removed duplicates when importing trace file
1 parent 3412be8 commit f9a4b51

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

packages/app/src/components/sidebar/explorer.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { html, css, nothing, type TemplateResult } from 'lit'
33
import { customElement } from 'lit/decorators.js'
44
import { consume } from '@lit/context'
55
import type { TestStats, SuiteStats } from '@wdio/reporter'
6-
6+
import { repeat } from 'lit/directives/repeat.js'
77
import { TestState } from './test-suite.js'
88
import { suiteContext } from '../../controller/DataManager.js'
99

@@ -20,6 +20,7 @@ import type { DevtoolsSidebarFilter } from './filter.js'
2020
const EXPLORER = 'wdio-devtools-sidebar-explorer'
2121

2222
interface 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>

packages/app/src/components/workbench/actions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,17 @@ export class DevtoolsActions extends Element {
7676
const allSuites = this.suites ? Object.values(this.suites).flatMap(s => Object.values(s)) : []
7777
const allItems = this._getActionItems(allSuites)
7878

79-
if (allItems.length === 0) {
79+
// Remove duplicates based on uid
80+
// Assuming each TestStats has a unique 'uid' property
81+
const uniqueItems = Array.from(new Map(allItems.map(item => [item.uid, item])).values())
82+
83+
if (uniqueItems.length === 0) {
8084
return html`<wdio-devtools-placeholder>No actions recorded.</wdio-devtools-placeholder>`
8185
}
8286

8387
return html`
8488
<div class="action-list">
85-
${allItems.map(item => this._renderStep(item as TestStats))}
89+
${uniqueItems.map(item => this._renderStep(item as TestStats))}
8690
</div>
8791
`
8892
}

packages/service/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export default class DevToolsHookService implements Services.ServiceInstance {
112112
if (isMultiRemote) {
113113
throw new SevereServiceError('The DevTools hook does not support multiremote yet')
114114
}
115-
// this.#sessionCapturer.readStepDefinitions(config)
116115

117116
if ('reporters' in config) {
118117
const self = this

0 commit comments

Comments
 (0)