Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: tv playback teaser (#39634)

Pavel Feldman0494a0ab53ad
diff --git a/packages/trace-viewer/src/ui/filmStrip.tsx b/packages/trace-viewer/src/ui/filmStrip.tsx
index c3910767c1..4fa56cfddc 100644
--- a/packages/trace-viewer/src/ui/filmStrip.tsx
+++ b/packages/trace-viewer/src/ui/filmStrip.tsx
@@ -76,10 +76,10 @@ export const FilmStrip: React.FunctionComponent<{
top: measure.bottom + 5,
left: Math.min(previewPoint!.x, measure.width - (previewSize ? previewSize.width : 0) - 10),
}}>
- {previewPoint.action && <div className='film-strip-hover-title'>{renderAction(previewPoint.action, previewPoint)}</div>}
{previewImage && previewSize && <div style={{ width: previewSize.width, height: previewSize.height }}>
<img src={model.createRelativeUrl(`sha1/${previewImage.sha1}`)} width={previewSize.width} height={previewSize.height} />
</div>}
+ {previewPoint.action && <div className='film-strip-hover-title'>{renderAction(previewPoint.action, previewPoint)}</div>}
</div>
}
</div>;
diff --git a/packages/trace-viewer/src/ui/playbackControl.css b/packages/trace-viewer/src/ui/playbackControl.css
new file mode 100644
index 0000000000..6299947d05
--- /dev/null
+++ b/packages/trace-viewer/src/ui/playbackControl.css
@@ -0,0 +1,91 @@
+/*
+ Copyright (c) Microsoft Corporation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+.playback-scrubber {
+ position: relative;
+ height: 16px;
+ cursor: pointer;
+ user-select: none;
+ flex: none;
+ outline: none;
+}
+
+.playback-scrubber:focus-visible .playback-thumb {
+ box-shadow: 0 0 0 2px var(--vscode-focusBorder);
+}
+
+.playback-track {
+ position: absolute;
+ top: 7px;
+ left: 0;
+ right: 0;
+ height: 2px;
+ background-color: var(--vscode-panel-border);
+ border-radius: 1px;
+}
+
+.playback-track-filled {
+ position: absolute;
+ top: 7px;
+ left: 0;
+ height: 2px;
+ background-color: var(--vscode-focusBorder);
+ border-radius: 1px;
+}
+
+.playback-track-filled.animated {
+ transition: width 150ms ease-out;
+}
+
+.playback-tick {
+ position: absolute;
+ top: 4px;
+ width: 1px;
+ height: 8px;
+ background-color: var(--vscode-foreground);
+}
+
+.playback-thumb {
+ position: absolute;
+ top: 3px;
+ width: 10px;
+ height: 10px;
+ margin-left: -5px;
+ border-radius: 50%;
+ background-color: var(--vscode-focusBorder);
+ z-index: 1;
+}
+
+.playback-thumb.animated {
+ transition: left 150ms ease-out;
+}
+
+.playback-speed {
+ background: none;
+ border: none;
+ color: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ padding: 2px 6px;
+ min-width: 36px;
+ text-align: center;
+ user-select: none;
+ border-radius: 3px;
+}
+
+.playback-speed:hover {
+ background-color: var(--vscode-toolbar-hoverBackground);
+}
diff --git a/packages/trace-viewer/src/ui/playbackControl.tsx b/packages/trace-viewer/src/ui/playbackControl.tsx
new file mode 100644
index 0000000000..e97bc082d4
--- /dev/null
+++ b/packages/trace-viewer/src/ui/playbackControl.tsx
@@ -0,0 +1,323 @@
+/*
+ Copyright (c) Microsoft Corporation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+import { ToolbarButton } from '@web/components/toolbarButton';
+import * as React from 'react';
+import type { ActionTraceEventInContext } from '@isomorphic/trace/traceModel';
+import type { Boundaries } from './geometry';
+import './playbackControl.css';
+
+const speeds = [0.5, 1, 2];
+
+export type PlaybackState = {
+ playing: boolean;
+ speed: number;
+ currentIndex: number;
+ percent: number;
+ animating: boolean;
+ togglePlay: () => void;
+ stop: () => void;
+ prev: () => void;
+ next: () => void;
+ cycleSpeed: () => void;
+ onScrubberMouseDown: (e: React.MouseEvent) => void;
+ scrubberRef: React.RefObject<HTMLDivElement | null>;
+ actionsLength: number;
+ canPrev: boolean;
+ canNext: boolean;
+ canStop: boolean;
+ ticks: number[] | undefined;
+};
+
+export function usePlayback(
+ actions: ActionTraceEventInContext[],
+ selectedAction: ActionTraceEventInContext | undefined,
+ onActionSelected: (action: ActionTraceEventInContext) => void,
+ timeWindow: Boundaries | undefined,
+ boundaries: Boundaries,
+): PlaybackState {
+ const [playing, setPlaying] = React.useState(false);
+ const [speedIndex, setSpeedIndex] = React.useState(1);
+ const [dragging, setDragging] = React.useState(false);
+ const [dragFraction, setDragFraction] = React.useState<number | undefined>(undefined);
+ const [cursorTime, setCursorTime] = React.useState<number | undefined>(undefined);
+ const speed = speeds[speedIndex];
+
+ const currentIndex = selectedAction ? actions.indexOf(selectedAction) : -1;
+
+ // Scrubber scale always matches the timeline boundaries (1:1 with timeline grid).
+ const fullMin = boundaries.minimum;
+ const fullMax = boundaries.maximum;
+ const fullDuration = fullMax - fullMin || 1;
+
+ // Playback boundaries: constrained to time window when selected.
+ const windowMin = timeWindow ? timeWindow.minimum : fullMin;
+ const windowMax = timeWindow ? timeWindow.maximum : fullMax;
+
+ // Actions within the effective window.
+ const windowActions = React.useMemo(() => {
+ if (!timeWindow)
+ return actions;
+ return actions.filter(a => a.startTime >= timeWindow.minimum && a.startTime <= timeWindow.maximum);
+ }, [actions, timeWindow]);
+
+ // First and last action indices within the window (in the full actions array).
+ const firstWindowIndex = windowActions.length ? actions.indexOf(windowActions[0]) : 0;
+ const lastWindowIndex = windowActions.length ? actions.indexOf(windowActions[windowActions.length - 1]) : actions.length - 1;
+
+ const actionsRef = React.useRef(actions);
+ actionsRef.current = actions;
+
+ const onActionSelectedRef = React.useRef(onActionSelected);
+ onActionSelectedRef.current = onActionSelected;
+
+ const scrubberRef = React.useRef<HTMLDivElement>(null);
+
+ const actionIndexAtTime = React.useCallback((t: number): number => {
+ let lo = 0, hi = actions.length - 1;
+ while (lo < hi) {
+ const mid = (lo + hi + 1) >> 1;
+ if (actions[mid].startTime <= t)
+ lo = mid;
+ else
+ hi = mid - 1;
+ }
+ if (lo < actions.length - 1) {
+ const distPrev = t - actions[lo].startTime;
+ const distNext = actions[lo + 1].startTime - t;
+ if (distNext < distPrev)
+ lo = lo + 1;
+ }
+ // Clamp to window bounds.
+ return Math.max(firstWindowIndex, Math.min(lastWindowIndex, lo));
+ }, [actions, firstWindowIndex, lastWindowIndex]);
+
+ const selectedTime = selectedAction ? selectedAction.startTime : fullMin;
+
+ let percent: number;
+ if (dragging && dragFraction !== undefined)
+ percent = dragFraction * 100;
+ else if (playing && cursorTime !== undefined)
+ percent = Math.max(0, Math.min(100, ((cursorTime - fullMin) / fullDuration) * 100));
+ else
+ percent = Math.max(0, Math.min(100, ((selectedTime - fullMin) / fullDuration) * 100));
+
+ // Refs for raf closure.
+ const windowMinRef = React.useRef(windowMin);
+ windowMinRef.current = windowMin;
+ const windowMaxRef = React.useRef(windowMax);
+ windowMaxRef.current = windowMax;
+
+ React.useEffect(() => {
+ if (!playing)
+ return;
+ let rafId: number;
+ let lastFrameTime: number | undefined;
+ let traceTime = selectedTime;
+ // If starting from before the window, jump to window start.
+ if (traceTime < windowMinRef.current)
+ traceTime = windowMinRef.current;
+ let lastSelectedIndex = currentIndex;
+
+ setCursorTime(traceTime);
+
+ const tick = (now: number) => {
+ if (lastFrameTime !== undefined) {
+ const delta = (now - lastFrameTime) * speed;
+ traceTime = Math.min(traceTime + delta, windowMaxRef.current);
+ }
+ lastFrameTime = now;
+ setCursorTime(traceTime);
+
+ const idx = actionIndexAtTime(traceTime);
+ if (idx !== lastSelectedIndex) {
+ lastSelectedIndex = idx;
+ onActionSelectedRef.current(actionsRef.current[idx]);
+ }
+
+ if (traceTime >= windowMaxRef.current) {
+ setPlaying(false);
+ return;
+ }
+ rafId = requestAnimationFrame(tick);
+ };
+ rafId = requestAnimationFrame(tick);
+ return () => cancelAnimationFrame(rafId);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [playing, speed]);
+
+ React.useEffect(() => {
+ if (!playing)
+ setCursorTime(undefined);
+ }, [playing]);
+
+ const togglePlay = React.useCallback(() => {
+ if (!actions.length)
+ return;
+ // Always restart from the window start when at the end (or beyond the window).
+ const atEnd = currentIndex >= lastWindowIndex;
+ if (!playing && atEnd)
+ onActionSelected(actions[firstWindowIndex]);
+ setPlaying(!playing);
+ }, [playing, actions, currentIndex, onActionSelected, firstWindowIndex, lastWindowIndex]);
+
+ const stop = React.useCallback(() => {
+ setPlaying(false);
+ if (actions.length)
+ onActionSelected(actions[firstWindowIndex]);
+ }, [actions, onActionSelected, firstWindowIndex]);
+
+ const prev = React.useCallback(() => {
+ const target = Math.max(currentIndex - 1, firstWindowIndex);
+ if (target !== currentIndex)
+ onActionSelected(actions[target]);
+ }, [actions, currentIndex, onActionSelected, firstWindowIndex]);
+
+ const next = React.useCallback(() => {
+ const target = Math.min(currentIndex + 1, lastWindowIndex);
+ if (target !== currentIndex)
+ onActionSelected(actions[target]);
+ }, [actions, currentIndex, onActionSelected, lastWindowIndex]);
+
+ const cycleSpeed = React.useCallback(() => {
+ setSpeedIndex(i => (i + 1) % speeds.length);
+ }, []);
+
+ React.useEffect(() => {
+ setPlaying(false);
+ }, [actions]);
+
+ const fractionFromMouseEvent = React.useCallback((e: MouseEvent | React.MouseEvent) => {
+ const rect = scrubberRef.current!.getBoundingClientRect();
+ return Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
+ }, []);
+
+ const selectActionAtFraction = React.useCallback((fraction: number) => {
+ if (!actions.length)
+ return;
+ const t = fullMin + fraction * fullDuration;
+ const idx = actionIndexAtTime(t);
+ onActionSelectedRef.current(actionsRef.current[idx]);
+ }, [actions, fullMin, fullDuration, actionIndexAtTime]);
+
+ const dragCleanupRef = React.useRef<(() => void) | null>(null);
+
+ React.useEffect(() => {
+ return () => dragCleanupRef.current?.();
+ }, []);
+
+ const onScrubberMouseDown = React.useCallback((e: React.MouseEvent) => {
+ if (!actions.length || e.button !== 0)
+ return;
+ e.preventDefault();
+ e.stopPropagation();
+ scrubberRef.current?.focus();
+ setDragging(true);
+ setPlaying(false);
+ const fraction = fractionFromMouseEvent(e);
+ setDragFraction(fraction);
+ selectActionAtFraction(fraction);
+
+ const onMouseMove = (me: MouseEvent) => {
+ const f = fractionFromMouseEvent(me);
+ setDragFraction(f);
+ selectActionAtFraction(f);
+ };
+ const onMouseUp = (me: MouseEvent) => {
+ document.removeEventListener('mousemove', onMouseMove);
+ document.removeEventListener('mouseup', onMouseUp);
+ dragCleanupRef.current = null;
+ const f = fractionFromMouseEvent(me);
+ selectActionAtFraction(f);
+ setDragFraction(undefined);
+ setDragging(false);
+ };
+ document.addEventListener('mousemove', onMouseMove);
+ document.addEventListener('mouseup', onMouseUp);
+ dragCleanupRef.current = () => {
+ document.removeEventListener('mousemove', onMouseMove);
+ document.removeEventListener('mouseup', onMouseUp);
+ };
+ }, [actions, selectActionAtFraction, fractionFromMouseEvent]);
+
+ const animating = !playing && !dragging;
+ const ticks = actions.length > 0 && actions.length <= 200 ? actions.map(a => ((a.startTime - fullMin) / fullDuration) * 100) : undefined;
+
+ const canPrev = currentIndex > firstWindowIndex;
+ const canNext = currentIndex < lastWindowIndex;
+ const canStop = playing || currentIndex > firstWindowIndex;
+
+ return {
+ playing, speed, currentIndex, percent, animating,
+ togglePlay, stop, prev, next, cycleSpeed,
+ onScrubberMouseDown, scrubberRef, actionsLength: actions.length,
+ canPrev, canNext, canStop, ticks,
+ };
+}
+
+export const PlaybackButtons: React.FC<{
+ playback: PlaybackState;
+}> = ({ playback }) => {
+ return <>
+ <ToolbarButton icon='chevron-left' title='Previous action' onClick={playback.prev} disabled={!playback.canPrev} />
+ <ToolbarButton icon={playback.playing ? 'debug-pause' : 'play'} disabled={!playback.actionsLength} title={playback.playing ? 'Pause' : 'Play'} onClick={playback.togglePlay} />
+ <ToolbarButton icon='debug-stop' title='Stop' onClick={playback.stop} disabled={!playback.canStop} />
+ <ToolbarButton icon='chevron-right' title='Next action' onClick={playback.next} disabled={!playback.canNext} />
+ <button className='playback-speed' onClick={playback.cycleSpeed} title='Playback speed'>
+ {playback.speed}x
+ </button>
+ </>;
+};
+
+export const PlaybackScrubber: React.FC<{
+ playback: PlaybackState;
+}> = ({ playback }) => {
+ const onKeyDown = React.useCallback((e: React.KeyboardEvent) => {
+ if (e.key === 'ArrowLeft') {
+ e.preventDefault();
+ playback.prev();
+ } else if (e.key === 'ArrowRight') {
+ e.preventDefault();
+ playback.next();
+ }
+ }, [playback]);
+
+ return <div
+ className='playback-scrubber'
+ ref={playback.scrubberRef}
+ onMouseDown={playback.onScrubberMouseDown}
+ onKeyDown={onKeyDown}
+ tabIndex={0}
+ role='slider'
+ aria-label='Playback position'
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={Math.round(playback.percent)}
+ >
+ <div className='playback-track' />
+ <div
+ className={'playback-track-filled' + (playback.animating ? ' animated' : '')}
+ style={{ 'width': `${playback.percent}%` }}
+ />
+ {playback.ticks?.map((p, i) => (
+ <div key={i} className='playback-tick' style={{ 'left': `${p}%` }} />
+ ))}
+ <div
+ className={'playback-thumb' + (playback.animating ? ' animated' : '')}
+ style={{ 'left': `${playback.percent}%` }}
+ />
+ </div>;
+};
diff --git a/packages/trace-viewer/src/ui/snapshotTab.tsx b/packages/trace-viewer/src/ui/snapshotTab.tsx
index fd8277e757..707e8f058a 100644
--- a/packages/trace-viewer/src/ui/snapshotTab.tsx
+++ b/packages/trace-viewer/src/ui/snapshotTab.tsx
@@ -33,6 +33,8 @@ import { BrowserFrame } from './browserFrame';
import type { ElementInfo } from '@recorder/recorderTypes';
import { parseAriaSnapshot } from '@isomorphic/ariaSnapshot';
import yaml from 'yaml';
+import { PlaybackButtons } from './playbackControl';
+import type { PlaybackState } from './playbackControl';
export type HighlightedElement = {
locator?: string,
@@ -49,7 +51,8 @@ export const SnapshotTabsView: React.FunctionComponent<{
setIsInspecting: (isInspecting: boolean) => void,
highlightedElement: HighlightedElement,
setHighlightedElement: (element: HighlightedElement) => void,
-}> = ({ action, model, sdkLanguage, testIdAttributeName, isInspecting, setIsInspecting, highlightedElement, setHighlightedElement }) => {
+ playback: PlaybackState
+}> = ({ action, model, sdkLanguage, testIdAttributeName, isInspecting, setIsInspecting, highlightedElement, setHighlightedElement, playback }) => {
const [snapshotTab, setSnapshotTab] = React.useState<'action'|'before'|'after'>('action');
const [shouldPopulateCanvasFromScreenshot] = useSetting('shouldPopulateCanvasFromScreenshot', false);
@@ -79,6 +82,7 @@ export const SnapshotTabsView: React.FunctionComponent<{
})}
</div>
<div style={{ flex: 'auto' }}></div>
+ <PlaybackButtons playback={playback} />
<ToolbarButton icon='link-external' title='Open snapshot in a new tab' disabled={!snapshotUrls?.popoutUrl} onClick={() => {
const win = window.open(snapshotUrls?.popoutUrl || '', '_blank');
win?.addEventListener('DOMContentLoaded', () => {
diff --git a/packages/trace-viewer/src/ui/timeline.css b/packages/trace-viewer/src/ui/timeline.css
index a94b4c1135..ccb98e2e5b 100644
--- a/packages/trace-viewer/src/ui/timeline.css
+++ b/packages/trace-viewer/src/ui/timeline.css
@@ -24,11 +24,10 @@
position: relative;
display: flex;
flex-direction: column;
- padding: 20px 0 4px;
+ padding-top: 16px;
cursor: text;
user-select: none;
margin-left: 10px;
- overflow-x: clip;
}
.timeline-divider {
@@ -52,14 +51,6 @@
cursor: pointer;
}
-.timeline-lane {
- pointer-events: none;
- overflow: hidden;
- flex: none;
- height: 20px;
- position: relative;
-}
-
.timeline-grid {
position: absolute;
top: 0;
@@ -68,80 +59,11 @@
left: 0;
}
-.timeline-bars {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- pointer-events: none;
-}
-
-.timeline-bar {
- position: absolute;
- --action-color: gray;
- --action-background-color: #88888802;
- border-top: 2px solid var(--action-color);
-}
-
-.timeline-bar.active {
- background-color: var(--action-background-color);
-}
-
-.timeline-bar.action {
- --action-color: var(--vscode-charts-orange);
- --action-background-color: #d1861666;
-}
-
-.timeline-bar.action.error {
- --action-color: var(--vscode-charts-red);
- --action-background-color: #e5140066;
-}
-
-.timeline-bar.network {
- --action-color: var(--vscode-charts-blue);
- --action-background-color: #1a85ff66;
-}
-
-.timeline-bar.console-message {
- --action-color: var(--vscode-charts-purple);
- --action-background-color: #1a85ff66;
-}
-
-:root.dark-mode .timeline-bar.action.error {
- --action-color: var(--vscode-errorForeground);
- --action-background-color: #f4877166;
-}
-
-.timeline-label {
- position: absolute;
- top: 0;
- bottom: 0;
- margin-left: 2px;
- background-color: var(--vscode-panel-background);
- justify-content: center;
- display: none;
- white-space: nowrap;
-}
-
-.timeline-label.selected {
- display: flex;
-}
-
-.timeline-marker {
- display: none;
- position: absolute;
- top: 0;
- bottom: 0;
- pointer-events: none;
- border-left: 3px solid var(--light-pink);
-}
-
.timeline-window {
display: flex;
position: absolute;
top: 0;
- bottom: 0;
+ bottom: 20px;
left: 0;
right: 0;
pointer-events: none;
diff --git a/packages/trace-viewer/src/ui/timeline.tsx b/packages/trace-viewer/src/ui/timeline.tsx
index 5b84793048..8da798d424 100644
--- a/packages/trace-viewer/src/ui/timeline.tsx
+++ b/packages/trace-viewer/src/ui/timeline.tsx
@@ -14,43 +14,26 @@
* limitations under the License.
*/
-import { useSetting, clsx, msToString, useMeasure } from '@web/uiUtils';
+import { useSetting, msToString, useMeasure } from '@web/uiUtils';
import { GlassPane } from '@web/shared/glassPane';
import * as React from 'react';
import type { Boundaries } from './geometry';
import { FilmStrip } from './filmStrip';
import type { FilmStripPreviewPoint } from './filmStrip';
-import type { ActionTraceEventInContext, ResourceEntry, TraceModel } from '@isomorphic/trace/traceModel';
+import type { ActionTraceEventInContext, TraceModel } from '@isomorphic/trace/traceModel';
import './timeline.css';
import type { Language } from '@isomorphic/locatorGenerators';
-import type { ConsoleEntry } from './consoleTab';
import type { ActionGroup } from '@isomorphic/protocolFormatter';
-type TimelineBar = {
- action?: ActionTraceEventInContext;
- resourceKey?: string;
- consoleMessage?: ConsoleEntry;
- leftPosition: number;
- rightPosition: number;
- leftTime: number;
- rightTime: number;
- active: boolean;
- error: boolean;
-};
-
export const Timeline: React.FunctionComponent<{
model: TraceModel | undefined,
- consoleEntries: ConsoleEntry[] | undefined,
- networkResources: ResourceEntry[] | undefined,
boundaries: Boundaries,
- highlightedAction: ActionTraceEventInContext | undefined,
- highlightedResourceKey: string | undefined,
- highlightedConsoleEntryOrdinal: number | undefined,
onSelected: (action: ActionTraceEventInContext) => void,
selectedTime: Boundaries | undefined,
setSelectedTime: (time: Boundaries | undefined) => void,
sdkLanguage: Language,
-}> = ({ model, boundaries, consoleEntries, networkResources, onSelected, highlightedAction, highlightedResourceKey, highlightedConsoleEntryOrdinal, selectedTime, setSelectedTime, sdkLanguage }) => {
+ scrubber?: React.ReactNode,
+}> = ({ model, boundaries, onSelected, selectedTime, setSelectedTime, sdkLanguage, scrubber }) => {
const [measure, ref] = useMeasure<HTMLDivElement>();
const [dragWindow, setDragWindow] = React.useState<{ startX: number, endX: number, pivot?: number, type: 'resize' | 'move' } | undefined>();
const [previewPoint, setPreviewPoint] = React.useState<FilmStripPreviewPoint | undefined>();
@@ -71,62 +54,6 @@ export const Timeline: React.FunctionComponent<{
const actions = React.useMemo(() => model?.filteredActions(actionsFilter), [model, actionsFilter]);
- const bars = React.useMemo(() => {
- const bars: TimelineBar[] = [];
- for (const entry of actions || []) {
- bars.push({
- action: entry,
- leftTime: entry.startTime,
- rightTime: entry.endTime || boundaries.maximum,
- leftPosition: timeToPosition(measure.width, boundaries, entry.startTime),
- rightPosition: timeToPosition(measure.width, boundaries, entry.endTime || boundaries.maximum),
- active: false,
- error: !!entry.error,
- });
- }
-
- for (const resource of model?.resources || []) {
- const startTime = resource._monotonicTime!;
- const endTime = resource._monotonicTime! + resource.time;
- bars.push({
- resourceKey: resource.id,
- leftTime: startTime,
- rightTime: endTime,
- leftPosition: timeToPosition(measure.width, boundaries, startTime),
- rightPosition: timeToPosition(measure.width, boundaries, endTime),
- active: false,
- error: false,
- });
- }
-
- for (const consoleMessage of consoleEntries || []) {
- bars.push({
- consoleMessage,
- leftTime: consoleMessage.timestamp,
- rightTime: consoleMessage.timestamp,
- leftPosition: timeToPosition(measure.width, boundaries, consoleMessage.timestamp),
- rightPosition: timeToPosition(measure.width, boundaries, consoleMessage.timestamp),
- active: false,
- error: consoleMessage.isError,
- });
- }
-
- return bars;
- }, [model, actions, consoleEntries, boundaries, measure]);
-
- React.useMemo(() => {
- for (const bar of bars) {
- if (highlightedAction)
- bar.active = bar.action === highlightedAction;
- else if (highlightedResourceKey)
- bar.active = bar.resourceKey === highlightedResourceKey;
- else if (highlightedConsoleEntryOrdinal !== undefined)
- bar.active = bar.consoleMessage === consoleEntries?.[highlightedConsoleEntryOrdinal];
- else
- bar.active = false;
- }
- }, [bars, highlightedAction, highlightedResourceKey, highlightedConsoleEntryOrdinal, consoleEntries]);
-
const onMouseDown = React.useCallback((event: React.MouseEvent) => {
setPreviewPoint(undefined);
if (!ref.current)
@@ -249,32 +176,8 @@ export const Timeline: React.FunctionComponent<{
</div>;
})
}</div>
- <div style={{ height: 8 }}></div>
<FilmStrip boundaries={boundaries} previewPoint={previewPoint} />
- <div className='timeline-bars'>{
- bars
- .filter(bar => !bar.action || bar.action.class !== 'Test')
- .map((bar, index) => {
- return <div key={index}
- className={clsx('timeline-bar',
- bar.action && 'action',
- bar.resourceKey && 'network',
- bar.consoleMessage && 'console-message',
- bar.active && 'active',
- bar.error && 'error')}
- style={{
- left: bar.leftPosition,
- width: Math.max(5, bar.rightPosition - bar.leftPosition),
- top: barTop(bar),
- bottom: 0,
- }}
- ></div>;
- })
- }</div>
- <div className='timeline-marker' style={{
- display: (previewPoint !== undefined) ? 'block' : 'none',
- left: (previewPoint?.x || 0) + 'px',
- }} />
+ {scrubber}
{selectedTime && <div className='timeline-window'>
<div className='timeline-window-curtain left' style={{ width: curtainLeft }}></div>
<div className='timeline-window-resizer' style={{ left: -5 }}></div>
@@ -325,7 +228,3 @@ function timeToPosition(clientWidth: number, boundaries: Boundaries, time: numbe
function positionToTime(clientWidth: number, boundaries: Boundaries, x: number): number {
return x / clientWidth * (boundaries.maximum - boundaries.minimum) + boundaries.minimum;
}
-
-function barTop(bar: TimelineBar): number {
- return bar.resourceKey ? 25 : 20;
-}
diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx
index faeba71468..78caf2f9d7 100644
--- a/packages/trace-viewer/src/ui/uiModeView.tsx
+++ b/packages/trace-viewer/src/ui/uiModeView.tsx
@@ -494,7 +494,7 @@ export const UIModeView: React.FC<{}> = ({
<div>Running {progress.passed}/{runningState.testIds.size} passed ({(progress.passed / runningState.testIds.size) * 100 | 0}%)</div>
</div>}
<ToolbarButton icon='play' title='Run all — F5' onClick={runVisibleTests} disabled={isRunningTest || isLoading}></ToolbarButton>
- <ToolbarButton icon='debug-stop' title={'Stop — ' + (isMac ? '⇧F5' : 'Shift + F5')} onClick={() => testServerConnection?.stopTests({})} disabled={!isRunningTest || isLoading}></ToolbarButton>
+ <ToolbarButton icon='debug-stop' title={'Stop — ' + (isMac ? '⇧F5' : 'Shift + F5')} onClick={() => testServerConnection?.stopTests({})} disabled={!isRunningTest || isLoading} testId={'stop-button'}></ToolbarButton>
<ToolbarButton icon='eye' title='Watch all' toggled={watchAll} onClick={() => {
setWatchedTreeIds({ value: new Set() });
setWatchAll(!watchAll);
diff --git a/packages/trace-viewer/src/ui/workbench.css b/packages/trace-viewer/src/ui/workbench.css
index 928b2e5845..5f778a2d0d 100644
--- a/packages/trace-viewer/src/ui/workbench.css
+++ b/packages/trace-viewer/src/ui/workbench.css
@@ -48,6 +48,7 @@
.workbench-action-filter {
margin-top: 3px;
border-bottom: 1px solid var(--vscode-panel-border);
+ flex: none;
}
.workbench-action-filter input[type=search] {
diff --git a/packages/trace-viewer/src/ui/workbench.tsx b/packages/trace-viewer/src/ui/workbench.tsx
index 59ca7c7819..77a4a290b6 100644
--- a/packages/trace-viewer/src/ui/workbench.tsx
+++ b/packages/trace-viewer/src/ui/workbench.tsx
@@ -28,6 +28,7 @@ import { SourceTab } from './sourceTab';
import { TabbedPane } from '@web/components/tabbedPane';
import type { TabbedPaneTabModel } from '@web/components/tabbedPane';
import { Timeline } from './timeline';
+import { usePlayback, PlaybackScrubber } from './playbackControl';
import { MetadataView } from './metadataView';
import { AttachmentsTab } from './attachmentsTab';
import { AnnotationsTab } from './annotationsTab';
@@ -84,9 +85,7 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
const [selectedTime, setSelectedTime] = usePartitionedState<Boundaries | undefined>('selectedTime');
const [highlightedCallId, setHighlightedCallId] = usePartitionedState<string | undefined>('highlightedCallId');
const [revealedErrorKey, setRevealedErrorKey] = usePartitionedState<string | undefined>('revealedErrorKey');
- const [highlightedConsoleMessageOrdinal, setHighlightedConsoleMessageOrdinal] = usePartitionedState<number | undefined>('highlightedConsoleMessageOrdinal');
const [revealedAttachmentCallId, setRevealedAttachmentCallId] = usePartitionedState<{ callId: string } | undefined>('revealedAttachmentCallId');
- const [highlightedResourceKey, setHighlightedResourceKey] = usePartitionedState<string | undefined>('highlightedResourceKey');
const [treeState, setTreeState] = usePartitionedState<TreeState>('treeState', { expandedItems: new Map() });
const [actionFilterText, setActionFilterText] = React.useState('');
@@ -152,6 +151,19 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
setHighlightedAction(undefined);
}, [setSelectedAction, setHighlightedAction]);
+ const { boundaries } = React.useMemo(() => {
+ const boundaries = { minimum: model?.startTime || 0, maximum: model?.endTime || 30000 };
+ if (boundaries.minimum > boundaries.maximum) {
+ boundaries.minimum = 0;
+ boundaries.maximum = 30000;
+ }
+ // Leave some nice free space on the right hand side.
+ boundaries.maximum += (boundaries.maximum - boundaries.minimum) / 20;
+ return { boundaries };
+ }, [model]);
+
+ const playback = usePlayback(actions || [], selectedAction, onActionSelected, selectedTime, boundaries);
+
const selectPropertiesTab = React.useCallback((tab: string) => {
setSelectedPropertiesTab(tab);
if (tab !== 'inspector')
@@ -252,14 +264,13 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
boundaries={boundaries}
selectedTime={selectedTime}
onAccepted={m => setSelectedTime({ minimum: m.timestamp, maximum: m.timestamp })}
- onEntryHovered={setHighlightedConsoleMessageOrdinal}
/>
};
const networkTab: TabbedPaneTabModel = {
id: 'network',
title: 'Network',
count: networkModel.resources.length,
- render: () => <NetworkTab boundaries={boundaries} networkModel={networkModel} onResourceHovered={setHighlightedResourceKey} sdkLanguage={model?.sdkLanguage ?? 'javascript'} />
+ render: () => <NetworkTab boundaries={boundaries} networkModel={networkModel} sdkLanguage={model?.sdkLanguage ?? 'javascript'} />
};
const attachmentsTab: TabbedPaneTabModel = {
id: 'attachments',
@@ -295,16 +306,6 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
tabs.splice(1, 0, sourceTab);
}
- const { boundaries } = React.useMemo(() => {
- const boundaries = { minimum: model?.startTime || 0, maximum: model?.endTime || 30000 };
- if (boundaries.minimum > boundaries.maximum) {
- boundaries.minimum = 0;
- boundaries.maximum = 30000;
- }
- // Leave some nice free space on the right hand side.
- boundaries.maximum += (boundaries.maximum - boundaries.minimum) / 20;
- return { boundaries };
- }, [model]);
let time: number = 0;
if (!isLive && model && model.endTime >= 0)
@@ -360,16 +361,12 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
return <div className='vbox workbench' {...(inert ? { inert: true } : {})}>
{!hideTimeline && <Timeline
model={model}
- consoleEntries={consoleModel.entries}
- networkResources={networkModel.resources}
boundaries={boundaries}
- highlightedAction={highlightedAction}
- highlightedResourceKey={highlightedResourceKey}
- highlightedConsoleEntryOrdinal={highlightedConsoleMessageOrdinal}
onSelected={onActionSelected}
sdkLanguage={sdkLanguage}
selectedTime={selectedTime}
setSelectedTime={setSelectedTime}
+ scrubber={<PlaybackScrubber playback={playback} />}
/>}
<SplitView
sidebarSize={250}
@@ -387,7 +384,8 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
isInspecting={isInspecting}
setIsInspecting={setIsInspecting}
highlightedElement={highlightedElement}
- setHighlightedElement={elementPicked} />}
+ setHighlightedElement={elementPicked}
+ playback={playback} />}
sidebar={
<TabbedPane
tabs={[actionsTab, metadataTab]}
diff --git a/packages/trace-viewer/src/ui/workbenchLoader.css b/packages/trace-viewer/src/ui/workbenchLoader.css
index 92d7347ae8..70c06a99be 100644
--- a/packages/trace-viewer/src/ui/workbenchLoader.css
+++ b/packages/trace-viewer/src/ui/workbenchLoader.css
@@ -112,23 +112,29 @@ body .drop-target {
height: 4px;
}
-.header {
+.workbench-loader-header {
display: flex;
- background-color: #000;
+ background-color: var(--vscode-sideBar-background);
flex: none;
flex-basis: 48px;
line-height: 48px;
font-size: 16px;
- color: #cccccc;
+ align-items: center;
+ box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px;
}
.workbench-loader {
contain: size;
}
-.workbench-loader .header .toolbar-button {
- margin: 12px;
- padding: 8px 4px;
+.workbench-loader .workbench-loader-header {
+ flex-basis: 32px;
+ line-height: 32px;
+ font-size: 13px;
+}
+
+.workbench-loader .workbench-loader-header .toolbar-button {
+ margin: 4px;
}
.workbench-loader .logo {
@@ -150,7 +156,7 @@ body .drop-target {
flex: none;
}
-.workbench-loader .header .title {
+.workbench-loader .workbench-loader-header .title {
margin-left: 16px;
overflow: hidden;
text-overflow: ellipsis;
diff --git a/packages/trace-viewer/src/ui/workbenchLoader.tsx b/packages/trace-viewer/src/ui/workbenchLoader.tsx
index abd83fca68..e3718e6336 100644
--- a/packages/trace-viewer/src/ui/workbenchLoader.tsx
+++ b/packages/trace-viewer/src/ui/workbenchLoader.tsx
@@ -192,7 +192,7 @@ export const WorkbenchLoader: React.FunctionComponent<{
if (event.dataTransfer.types.includes('Files'))
setDragOver(true);
}}>
- <div className='hbox header' {...(showFileUploadDropArea ? { inert: true } : {})}>
+ <div className='hbox workbench-loader-header' {...(showFileUploadDropArea ? { inert: true } : {})}>
<div className='logo'>
<img src='playwright-logo.svg' alt='Playwright logo' />
</div>
diff --git a/packages/web/src/components/treeView.tsx b/packages/web/src/components/treeView.tsx
index b2f98af0dc..2f406180bb 100644
--- a/packages/web/src/components/treeView.tsx
+++ b/packages/web/src/components/treeView.tsx
@@ -73,7 +73,6 @@ export function TreeView<T extends TreeItem>({
const itemListRef = React.useRef<HTMLDivElement>(null);
const [highlightedItem, setHighlightedItem] = React.useState<any>();
- const [isKeyboardNavigation, setIsKeyboardNavigation] = React.useState(false);
React.useEffect(() => {
onHighlighted?.(highlightedItem);
@@ -180,12 +179,9 @@ export function TreeView<T extends TreeItem>({
}
}
- // scrollIntoViewIfNeeded(element || undefined);
onHighlighted?.(undefined);
- if (newSelectedItem) {
- setIsKeyboardNavigation(true);
+ if (newSelectedItem)
onSelected?.(newSelectedItem);
- }
setHighlightedItem(undefined);
}}
ref={itemListRef}
@@ -207,9 +203,7 @@ export function TreeView<T extends TreeItem>({
setHighlightedItem={setHighlightedItem}
render={render}
icon={icon}
- title={title}
- isKeyboardNavigation={isKeyboardNavigation}
- setIsKeyboardNavigation={setIsKeyboardNavigation} />;
+ title={title} />;
})}
</div>
</div>;
@@ -229,8 +223,6 @@ type TreeItemHeaderProps<T> = {
render: (item: T) => React.ReactNode,
title?: (item: T) => string,
icon?: (item: T) => string | undefined,
- isKeyboardNavigation: boolean,
- setIsKeyboardNavigation: (value: boolean) => void,
};
export function TreeItemHeader<T extends TreeItem>({
@@ -246,18 +238,14 @@ export function TreeItemHeader<T extends TreeItem>({
toggleSubtree,
render,
title,
- icon,
- isKeyboardNavigation,
- setIsKeyboardNavigation }: TreeItemHeaderProps<T>) {
+ icon }: TreeItemHeaderProps<T>) {
const groupId = React.useId();
const itemRef = React.useRef(null);
React.useEffect(() => {
- if (selectedItem === item && isKeyboardNavigation && itemRef.current) {
+ if (selectedItem?.id === item.id && itemRef.current)
scrollIntoViewIfNeeded(itemRef.current);
- setIsKeyboardNavigation(false);
- }
- }, [item, selectedItem, isKeyboardNavigation, setIsKeyboardNavigation]);
+ }, [item.id, selectedItem?.id]);
const itemData = treeItems.get(item)!;
const indentation = itemData.depth;
@@ -320,9 +308,7 @@ export function TreeItemHeader<T extends TreeItem>({
setHighlightedItem={setHighlightedItem}
render={render}
title={title}
- icon={icon}
- isKeyboardNavigation={isKeyboardNavigation}
- setIsKeyboardNavigation={setIsKeyboardNavigation} />;
+ icon={icon} />;
})}
</div>}
</div>;
diff --git a/tests/library/trace-viewer-scrub.spec.ts b/tests/library/trace-viewer-scrub.spec.ts
new file mode 100644
index 0000000000..c1c609c055
--- /dev/null
+++ b/tests/library/trace-viewer-scrub.spec.ts
@@ -0,0 +1,195 @@
+/**
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { TraceViewerFixtures } from '../config/traceViewerFixtures';
+import { traceViewerFixtures } from '../config/traceViewerFixtures';
+import { expect, playwrightTest } from '../config/browserTest';
+
+const test = playwrightTest.extend<TraceViewerFixtures>(traceViewerFixtures);
+
+test.skip(({ trace }) => trace === 'on');
+test.skip(({ mode }) => mode.startsWith('service'));
+test.skip(process.env.PW_CLOCK === 'frozen');
+test.slow();
+
+test('should show playback controls', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ });
+ const page = traceViewer.page;
+ await expect(page.getByRole('slider', { name: 'Playback position' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Play' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Stop' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Previous action' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Next action' })).toBeVisible();
+ await expect(page.locator('.playback-speed')).toBeVisible();
+});
+
+test('should navigate with next and previous buttons', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+
+ // Select the first action.
+ await traceViewer.selectAction('Set content');
+
+ // Click next to advance.
+ await page.getByRole('button', { name: 'Next action' }).click();
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Click/);
+
+ // Click next again.
+ await page.getByRole('button', { name: 'Next action' }).click();
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Set content/);
+
+ // Click previous to go back.
+ await page.getByRole('button', { name: 'Previous action' }).click();
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Click/);
+});
+
+test('should cycle playback speed', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ });
+ const page = traceViewer.page;
+ const speedButton = page.locator('.playback-speed');
+
+ await expect(speedButton).toHaveText('1x');
+ await speedButton.click();
+ await expect(speedButton).toHaveText('2x');
+ await speedButton.click();
+ await expect(speedButton).toHaveText('0.5x');
+ await speedButton.click();
+ await expect(speedButton).toHaveText('1x');
+});
+
+test('should stop and reset to first action', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+
+ // Navigate to a later action.
+ await traceViewer.selectAction('Click');
+
+ // Click stop — should reset to first action.
+ await page.getByRole('button', { name: 'Stop' }).click();
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Set content/);
+});
+
+test('should support keyboard navigation on scrubber', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+ const scrubber = page.getByRole('slider', { name: 'Playback position' });
+
+ // Select first action and focus scrubber.
+ await traceViewer.selectAction('Set content');
+ await scrubber.focus();
+
+ // ArrowRight should go to next action.
+ await page.keyboard.press('ArrowRight');
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Click/);
+
+ // ArrowRight again.
+ await page.keyboard.press('ArrowRight');
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Set content/);
+
+ // ArrowLeft should go back.
+ await page.keyboard.press('ArrowLeft');
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Click/);
+});
+
+test('should have tick marks on scrubber', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+
+ // There should be tick marks for each action.
+ const ticks = page.locator('.playback-tick');
+ await expect(ticks).toHaveCount(3);
+});
+
+test('should play and auto-stop at end', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ });
+ const page = traceViewer.page;
+
+ // Select first action.
+ await traceViewer.selectAction('Set content');
+
+ // Hit play.
+ await page.getByRole('button', { name: 'Play' }).click();
+
+ // Should auto-stop — play button should reappear (not pause).
+ await expect(page.getByRole('button', { name: 'Play' })).toBeVisible({ timeout: 10000 });
+
+ // Should have advanced to last action.
+ await expect(traceViewer.actionsTree.getByRole('treeitem', { selected: true })).toHaveText(/Click/);
+});
+
+test('should update scrubber aria-valuenow', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+ const scrubber = page.getByRole('slider', { name: 'Playback position' });
+
+ // Select first action - should have low value.
+ await traceViewer.selectAction('Set content');
+ const val1 = await scrubber.getAttribute('aria-valuenow');
+
+ // Select last action - should have higher value.
+ await traceViewer.selectAction('Set content', 1);
+ const val2 = await scrubber.getAttribute('aria-valuenow');
+
+ expect(Number(val2)).toBeGreaterThan(Number(val1));
+});
+
+test('should drag scrubber to select action', async ({ runAndTrace, page: actionPage }) => {
+ const traceViewer = await runAndTrace(async () => {
+ await actionPage.setContent('<button>Click me</button>');
+ await actionPage.click('button');
+ await actionPage.setContent('<input/>');
+ });
+ const page = traceViewer.page;
+ const scrubber = page.getByRole('slider', { name: 'Playback position' });
+
+ // Click near the end of the scrubber to select a later action.
+ const box = await scrubber.boundingBox();
+ expect(box).toBeTruthy();
+ await page.mouse.click(box!.x + box!.width * 0.95, box!.y + box!.height / 2);
+
+ // Should have selected a later action (not the first one).
+ const scrubberValue = await scrubber.getAttribute('aria-valuenow');
+ expect(Number(scrubberValue)).toBeGreaterThan(50);
+});
diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts
index d3d12eb247..f3fda49466 100644
--- a/tests/library/trace-viewer.spec.ts
+++ b/tests/library/trace-viewer.spec.ts
@@ -309,13 +309,6 @@ test('should contain action info', async ({ showTraceViewer }) => {
]);
});
-test('should render network bars', async ({ page, runAndTrace, server }) => {
- const traceViewer = await runAndTrace(async () => {
- await page.goto(server.EMPTY_PAGE);
- });
- await expect(traceViewer.page.locator('.timeline-bar.network')).toHaveCount(1);
-});
-
test('should render console', async ({ showTraceViewer, browserName }) => {
const traceViewer = await showTraceViewer(traceFile);
await traceViewer.showConsoleTab();
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index e2dbfadef1..cc996651d1 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -652,7 +652,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await page.getByRole('link', { name: 'passes' }).click();
await page.click('img');
await expect(page.locator('.progress-dialog')).toBeHidden();
- await expect(page.locator('.workbench-loader > .header > .title')).toHaveText('a.test.js:3 › passes');
+ await expect(page.locator('.workbench-loader > .workbench-loader-header > .title')).toHaveText('a.test.js:3 › passes');
});
test('should show multi trace source', async ({ runInlineTest, page, server, showReport }) => {
diff --git a/tests/playwright-test/ui-mode-test-output.spec.ts b/tests/playwright-test/ui-mode-test-output.spec.ts
index c3426f8f46..1219561893 100644
--- a/tests/playwright-test/ui-mode-test-output.spec.ts
+++ b/tests/playwright-test/ui-mode-test-output.spec.ts
@@ -236,7 +236,7 @@ test('should stream console messages live', async ({ runUITest }) => {
'I was logged',
'I was clicked',
]);
- await page.getByTitle('Stop').click();
+ await page.getByTestId('stop-button').click();
});
test('should print beforeAll console messages once', async ({ runUITest }, testInfo) => {
diff --git a/tests/playwright-test/ui-mode-test-run.spec.ts b/tests/playwright-test/ui-mode-test-run.spec.ts
index e99c13b9a5..6d79692a8e 100644
--- a/tests/playwright-test/ui-mode-test-run.spec.ts
+++ b/tests/playwright-test/ui-mode-test-run.spec.ts
@@ -97,7 +97,7 @@ test('should show running progress', async ({ runUITest }) => {
await page.getByTitle('Run all').click();
await expect(page.getByTestId('status-line')).toHaveText('Running 1/4 passed (25%)');
- await page.getByTitle('Stop').click();
+ await page.getByTestId('stop-button').click();
await expect(page.getByTestId('status-line')).toHaveText('1/4 passed (25%)');
await page.getByTitle('Reload').click();
await expect(page.getByTestId('status-line')).toBeHidden();
@@ -365,7 +365,7 @@ test('should stop', async ({ runUITest }) => {
});
await expect(page.getByTitle('Run all')).toBeEnabled();
- await expect(page.getByTitle('Stop')).toBeDisabled();
+ await expect(page.getByTestId('stop-button')).toBeDisabled();
await page.getByTitle('Run all').click();
@@ -388,9 +388,9 @@ test('should stop', async ({ runUITest }) => {
`);
await expect(page.getByTitle('Run all')).toBeDisabled();
- await expect(page.getByTitle('Stop')).toBeEnabled();
+ await expect(page.getByTestId('stop-button')).toBeEnabled();
- await page.getByTitle('Stop').click();
+ await page.getByTestId('stop-button').click();
await expect.poll(dumpTestTree(page)).toBe(`
▼ ◯ a.test.ts
diff --git a/tests/playwright-test/ui-mode-test-shortcut.spec.ts b/tests/playwright-test/ui-mode-test-shortcut.spec.ts
index 9dd73f3e90..6d9b0eba5d 100644
--- a/tests/playwright-test/ui-mode-test-shortcut.spec.ts
+++ b/tests/playwright-test/ui-mode-test-shortcut.spec.ts
@@ -32,7 +32,7 @@ test('should run tests', async ({ runUITest }) => {
const { page } = await runUITest(basicTestTree);
await expect(page.getByTitle('Run all')).toBeEnabled();
- await expect(page.getByTitle('Stop')).toBeDisabled();
+ await expect(page.getByTestId('stop-button')).toBeDisabled();
await page.getByPlaceholder('Filter (e.g. text, @tag)').fill('test 3');
await page.keyboard.press('F5');
@@ -64,7 +64,7 @@ test('should stop tests', async ({ runUITest }) => {
const { page } = await runUITest(basicTestTree);
await expect(page.getByTitle('Run all')).toBeEnabled();
- await expect(page.getByTitle('Stop')).toBeDisabled();
+ await expect(page.getByTestId('stop-button')).toBeDisabled();
await page.getByTitle('Run all').click();
@@ -87,7 +87,7 @@ test('should stop tests', async ({ runUITest }) => {
`);
await expect(page.getByTitle('Run all')).toBeDisabled();
- await expect(page.getByTitle('Stop')).toBeEnabled();
+ await expect(page.getByTestId('stop-button')).toBeEnabled();
await page.keyboard.press('Shift+F5');
@@ -104,7 +104,7 @@ test('should toggle Terminal', async ({ runUITest }) => {
const { page } = await runUITest(basicTestTree);
await expect(page.getByTitle('Run all')).toBeEnabled();
- await expect(page.getByTitle('Stop')).toBeDisabled();
+ await expect(page.getByTestId('stop-button')).toBeDisabled();
await expect(page.getByTestId('output')).toBeHidden();