Skip to content

Commit 0207f58

Browse files
committed
Iframe UI update
1 parent 5bf6519 commit 0207f58

File tree

2 files changed

+62
-116
lines changed

2 files changed

+62
-116
lines changed

packages/app/src/components/browser/snapshot.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,20 @@ export class DevtoolsBrowser extends Element {
5050
width: 100%;
5151
height: 100%;
5252
display: flex;
53-
margin: 2rem;
53+
padding: 2rem;
5454
align-items: center;
5555
justify-content: center;
5656
}
5757
58+
section {
59+
box-sizing: border-box;
60+
width: calc(100% - 0px); /* host padding already applied */
61+
height: calc(100% - 0px);
62+
display: flex;
63+
flex-direction: column;
64+
overflow: hidden;
65+
}
66+
5867
.frame-dot {
5968
border-radius: 50%;
6069
height: 12px;
Lines changed: 52 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,72 @@
11
import { Element } from '@core/element'
2-
import { html, css, type TemplateResult } from 'lit'
3-
import { customElement, state } from 'lit/decorators.js'
2+
import { html, css } from 'lit'
3+
import { customElement } from 'lit/decorators.js'
44
import { consume } from '@lit/context'
5-
import type { SuiteStats, TestStats } from '@wdio/reporter'
6-
import { suiteContext, commandContext, type CommandLog } from '../../controller/DataManager.js'
5+
6+
import { mutationContext, type TraceMutation, commandContext, type CommandLog } from '../../controller/DataManager.js'
7+
8+
import '~icons/mdi/pencil.js'
9+
import '~icons/mdi/family-tree.js'
10+
import '~icons/mdi/alert.js'
11+
import '~icons/mdi/document.js'
12+
import '~icons/mdi/arrow-right.js'
713

814
import '../placeholder.js'
915
import './actionItems/command.js'
10-
import '../../components/sidebar/collapseableEntry.js'
11-
import '~icons/mdi/play-box-outline.js'
16+
import './actionItems/mutation.js'
1217

13-
type ActionItem = TestStats;
18+
const SOURCE_COMPONENT = 'wdio-devtools-actions'
1419

15-
@customElement('wdio-devtools-actions')
20+
@customElement(SOURCE_COMPONENT)
1621
export class DevtoolsActions extends Element {
17-
@consume({ context: suiteContext, subscribe: true })
18-
suites?: Record<string, SuiteStats>[] = []
22+
static styles = [...Element.styles, css`
23+
:host {
24+
display: flex;
25+
flex-direction: column;
26+
width: 100%;
27+
}
28+
`]
29+
30+
@consume({ context: mutationContext, subscribe: true })
31+
mutations: TraceMutation[] = []
1932

2033
@consume({ context: commandContext, subscribe: true })
21-
commands?: CommandLog[] = []
34+
commands: CommandLog[] = []
2235

23-
@state()
24-
private _expandedItemId: string | null = null
36+
render() {
37+
const mutations = this.mutations || []
38+
const commands = this.commands || []
39+
const entries = [...mutations, ...commands]
40+
.sort((a, b) => a.timestamp - b.timestamp)
2541

26-
private _getActionItems(suites: SuiteStats[]): ActionItem[] {
27-
let items: ActionItem[] = []
28-
for (const suite of suites) {
29-
items = items.concat(suite.tests)
30-
if (suite.suites) {
31-
items = items.concat(this._getActionItems(suite.suites))
32-
}
42+
if (!entries.length || !mutations.length) {
43+
return html`<wdio-devtools-placeholder></wdio-devtools-placeholder>`
3344
}
34-
return items.sort((a, b) => {
35-
const startTimeA = a.start ? new Date(a.start).getTime() : 0;
36-
const startTimeB = b.start ? new Date(b.start).getTime() : 0;
37-
return startTimeA - startTimeB;
38-
});
39-
}
4045

41-
// Renders a test step as a collapsible entry
42-
private _renderStep(step: TestStats): TemplateResult {
43-
if (!this.commands) return html``
46+
return entries.map((entry) => {
47+
const elapsedTime = entry.timestamp - mutations[0].timestamp
4448

45-
const stepCommands = this.commands.filter(cmd => {
46-
const startTime = step.start ? new Date(step.start).getTime() : 0;
47-
const endTime = step.end ? new Date(step.end).getTime() : Infinity;
48-
return cmd.timestamp >= startTime && cmd.timestamp <= endTime;
49-
});
50-
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;
49+
if ('command' in entry) {
50+
return html`
51+
<wdio-devtools-command-item
52+
elapsedTime=${elapsedTime}
53+
.entry=${entry}
54+
></wdio-devtools-command-item>
55+
`
56+
}
5457

55-
return html`
56-
<wdio-collapsable-entry
57-
.isInitiallyOpen=${this._expandedItemId === step.uid}
58-
@click=${() => this._expandedItemId = this._expandedItemId === step.uid ? null : step.uid}
59-
>
60-
<div slot="summary" class="step-summary">
61-
<icon-mdi-play-box-outline class="icon"></icon-mdi-play-box-outline>
62-
<span class="title">${step.title}</span>
63-
<span class="duration">${duration}ms</span>
64-
</div>
65-
<div class="commands">
66-
${stepCommands.length > 0
67-
? stepCommands.map(command => html`<wdio-devtools-command-item .entry=${command}></wdio-devtools-command-item>`)
68-
: html`<div class="no-commands">No commands recorded for this step.</div>`
69-
}
70-
</div>
71-
</wdio-collapsable-entry>
72-
`
58+
return html`
59+
<wdio-devtools-mutation-item
60+
elapsedTime=${elapsedTime}
61+
.entry=${entry}
62+
></wdio-devtools-mutation-item>
63+
`
64+
})
7365
}
66+
}
7467

75-
render() {
76-
const allSuites = this.suites ? Object.values(this.suites).flatMap(s => Object.values(s)) : []
77-
const allItems = this._getActionItems(allSuites)
78-
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) {
84-
return html`<wdio-devtools-placeholder>No actions recorded.</wdio-devtools-placeholder>`
85-
}
86-
87-
return html`
88-
<div class="action-list">
89-
${uniqueItems.map(item => this._renderStep(item as TestStats))}
90-
</div>
91-
`
68+
declare global {
69+
interface HTMLElementTagNameMap {
70+
[SOURCE_COMPONENT]: DevtoolsActions
9271
}
93-
94-
static styles = [...Element.styles, css`
95-
:host, .action-list {
96-
width: 100%;
97-
height: 100%;
98-
}
99-
100-
.step-summary {
101-
display: flex;
102-
align-items: center;
103-
padding: 0.6rem 1rem;
104-
border-bottom: 1px solid var(--vscode-panel-border);
105-
gap: 0.5rem;
106-
font-size: 0.9em;
107-
cursor: pointer;
108-
}
109-
.step-summary:hover {
110-
background-color: var(--vscode-toolbar-hoverBackground);
111-
}
112-
.icon {
113-
width: 1.1rem;
114-
height: 1.1rem;
115-
flex-shrink: 0;
116-
color: var(--vscode-descriptionForeground);
117-
}
118-
.title {
119-
flex-grow: 1;
120-
}
121-
.duration {
122-
font-size: 0.9em;
123-
color: var(--vscode-descriptionForeground);
124-
}
125-
.commands {
126-
padding-left: 2rem;
127-
border-bottom: 1px solid var(--vscode-panel-border);
128-
}
129-
.no-commands {
130-
padding: 0.5rem 1.5rem;
131-
color: var(--vscode-descriptionForeground);
132-
font-style: italic;
133-
}
134-
`]
13572
}

0 commit comments

Comments
 (0)