Skip to content

Commit 15aa04a

Browse files
committed
Action tab cleanup
1 parent e309cab commit 15aa04a

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

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

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ import { Element } from '@core/element'
22
import { html, css, type TemplateResult } from 'lit'
33
import { customElement, state } from 'lit/decorators.js'
44
import { consume } from '@lit/context'
5-
import type { SuiteStats, TestStats, HookStats } from '@wdio/reporter'
5+
import type { SuiteStats, TestStats } from '@wdio/reporter'
66
import { suiteContext, commandContext, type CommandLog } from '../../controller/DataManager.js'
77

88
import '../placeholder.js'
99
import './actionItems/command.js'
1010
import '../../components/sidebar/collapseableEntry.js'
11-
import '~icons/mdi/sync.js'
1211
import '~icons/mdi/play-box-outline.js'
1312

14-
// A type to represent any high-level item in our action list
15-
type ActionItem = TestStats | HookStats;
13+
type ActionItem = TestStats;
1614

1715
@customElement('wdio-devtools-actions')
1816
export class DevtoolsActions extends Element {
@@ -25,46 +23,35 @@ export class DevtoolsActions extends Element {
2523
@state()
2624
private _expandedItemId: string | null = null
2725

28-
// Helper to get a flat, chronological list of all hooks and test steps
2926
private _getActionItems(suites: SuiteStats[]): ActionItem[] {
3027
let items: ActionItem[] = []
3128
for (const suite of suites) {
32-
items = items.concat(suite.hooks)
3329
items = items.concat(suite.tests)
3430
if (suite.suites) {
3531
items = items.concat(this._getActionItems(suite.suites))
3632
}
3733
}
38-
// Correctly sort by converting date strings to Date objects first
3934
return items.sort((a, b) => {
4035
const startTimeA = a.start ? new Date(a.start).getTime() : 0;
4136
const startTimeB = b.start ? new Date(b.start).getTime() : 0;
4237
return startTimeA - startTimeB;
4338
});
4439
}
4540

46-
// Renders a "before" or "after" hook
47-
private _renderHook(hook: HookStats): TemplateResult {
48-
return html`
49-
<div class="hook-item">
50-
<icon-mdi-sync class="icon"></icon-mdi-sync>
51-
<span class="title">Hook: "${hook.title}"</span>
52-
<span class="duration">${hook.duration}ms</span>
53-
</div>
54-
`
55-
}
56-
57-
// Renders a test step (e.g., "Given..." or an "it" block) as a collapsible entry
41+
// Renders a test step as a collapsible entry
5842
private _renderStep(step: TestStats): TemplateResult {
5943
if (!this.commands) return html``
6044

61-
// Find all low-level commands that were executed during this specific step
6245
const stepCommands = this.commands.filter(cmd => {
6346
const startTime = step.start ? new Date(step.start).getTime() : 0;
6447
const endTime = step.end ? new Date(step.end).getTime() : Infinity;
6548
return cmd.timestamp >= startTime && cmd.timestamp <= endTime;
6649
});
6750

51+
const startTime = step.start ? new Date(step.start).getTime() : 0;
52+
const endTime = step.end ? new Date(step.end).getTime() : 0;
53+
const duration = endTime > 0 ? endTime - startTime : 0;
54+
6855
return html`
6956
<wdio-collapsable-entry
7057
.isInitiallyOpen=${this._expandedItemId === step.uid}
@@ -73,7 +60,7 @@ export class DevtoolsActions extends Element {
7360
<div slot="summary" class="step-summary">
7461
<icon-mdi-play-box-outline class="icon"></icon-mdi-play-box-outline>
7562
<span class="title">${step.title}</span>
76-
<span class="duration">${step.duration}ms</span>
63+
<span class="duration">${duration}ms</span>
7764
</div>
7865
<div class="commands">
7966
${stepCommands.length > 0
@@ -95,10 +82,7 @@ export class DevtoolsActions extends Element {
9582

9683
return html`
9784
<div class="action-list">
98-
${allItems.map(item => 'type' in item && item.type === 'hook'
99-
? this._renderHook(item as HookStats)
100-
: this._renderStep(item as TestStats)
101-
)}
85+
${allItems.map(item => this._renderStep(item as TestStats))}
10286
</div>
10387
`
10488
}
@@ -109,15 +93,14 @@ export class DevtoolsActions extends Element {
10993
height: 100%;
11094
overflow-y: auto;
11195
}
112-
.hook-item, .step-summary {
96+
97+
.step-summary {
11398
display: flex;
11499
align-items: center;
115100
padding: 0.6rem 1rem;
116101
border-bottom: 1px solid var(--vscode-panel-border);
117102
gap: 0.5rem;
118103
font-size: 0.9em;
119-
}
120-
.step-summary {
121104
cursor: pointer;
122105
}
123106
.step-summary:hover {

0 commit comments

Comments
 (0)