Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(trace-viewer): use ToolbarButton for Show all and the console badge (#42336)
Yury Semikhatsky6e8015ac6843
diff --git a/packages/trace-viewer/src/ui/actionList.css b/packages/trace-viewer/src/ui/actionList.cssindex 435b6ada3f..f600b25cce 100644--- a/packages/trace-viewer/src/ui/actionList.css+++ b/packages/trace-viewer/src/ui/actionList.css@@ -74,21 +74,6 @@padding-right: 3px;}-.action-icons {- flex: none;- display: flex;- flex-direction: row;- cursor: pointer;- height: 20px;- position: relative;- top: 1px;- border-bottom: 1px solid transparent;-}--.action-icons:hover {- border-bottom: 1px solid var(--vscode-sideBarTitle-foreground);-}-.action-error {color: var(--vscode-errorForeground);position: relative;@@ -118,10 +103,8 @@}.action-list-show-all {- display: flex;- cursor: pointer;+ align-self: flex-start;height: 28px;- align-items: center;}.action-list-container {diff --git a/packages/trace-viewer/src/ui/actionList.tsx b/packages/trace-viewer/src/ui/actionList.tsxindex a9c871a9b3..bf6e2ff314 100644--- a/packages/trace-viewer/src/ui/actionList.tsx+++ b/packages/trace-viewer/src/ui/actionList.tsx@@ -112,7 +112,7 @@ export const ActionList: React.FC<ActionListProps> = ({}, [setSelectedTime]);return <div className='vbox action-list-container'>- {selectedTime && <div className='action-list-show-all' onClick={onShowAll}><span className='codicon codicon-triangle-left'></span>Show all</div>}+ {selectedTime && <ToolbarButton className='action-list-show-all' icon='triangle-left' onClick={onShowAll}>Show all</ToolbarButton>}<ActionTreeViewname='actions'rootItem={rootItem}@@ -145,6 +145,7 @@ export const renderAction = (}) => {const { model, sdkLanguage, revealConsole, revealActionAttachment, isLive, showDuration, showBadges, showAttachments } = options;const { errors, warnings } = model?.stats(action) ?? { errors: 0, warnings: 0 };+ const badgeLabel = [pluralize(errors, 'error'), pluralize(warnings, 'warning')].filter(Boolean).join(', ');const locator = action.params.selector ? asLocatorDescription(sdkLanguage || 'javascript', action.params.selector) : undefined;@@ -164,10 +165,14 @@ export const renderAction = ({showAttachments && <ToolbarButton icon='attach' title='Open Attachment' onClick={() => revealActionAttachment?.()} />}{showDuration && !isSkipped && <div className='action-duration'>{time || <span className='codicon codicon-loading'></span>}</div>}{isSkipped && <span className={clsx('action-skipped', 'codicon', testStatusIcon('skipped'))} title='skipped'></span>}- {showBadges && <div className='action-icons' onClick={() => revealConsole?.()}>- {!!errors && <div className='action-icon'><span className='codicon codicon-error'></span><span className='action-icon-value'>{errors}</span></div>}- {!!warnings && <div className='action-icon'><span className='codicon codicon-warning'></span><span className='action-icon-value'>{warnings}</span></div>}- </div>}+ {showBadges && !!badgeLabel && <ToolbarButton+ className='action-icons'+ title='Reveal console'+ ariaLabel={`Reveal console, ${badgeLabel}`}+ onClick={() => revealConsole?.()}>+ {!!errors && <span className='action-icon'><span className='codicon codicon-error'></span><span className='action-icon-value'>{errors}</span></span>}+ {!!warnings && <span className='action-icon'><span className='codicon codicon-warning'></span><span className='action-icon-value'>{warnings}</span></span>}+ </ToolbarButton>}</div>{locator && <div className='action-title-selector' title={locator}>{locator}</div>}</div>;@@ -217,3 +222,9 @@ export function renderTitleForCall(action: ActionTraceEvent, sdkLanguage?: Langu}return { elements, title: title.join('') };}++function pluralize(count: number, noun: string): string {+ if (!count)+ return '';+ return `${count} ${noun}${count === 1 ? '' : 's'}`;+}diff --git a/packages/web/src/components/treeView.tsx b/packages/web/src/components/treeView.tsxindex a2d584bb86..a268678bfc 100644--- a/packages/web/src/components/treeView.tsx+++ b/packages/web/src/components/treeView.tsx@@ -141,7 +141,8 @@ export function TreeView<T extends TreeItem>({role={treeItems.size > 0 ? 'tree' : undefined}tabIndex={0}onKeyDown={event => {- if (selectedItem && event.key === 'Enter') {+ // Enter is handled by the focused button inside the row, if any.+ if (selectedItem && event.key === 'Enter' && event.target === event.currentTarget) {onAccepted?.(selectedItem);return;}diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex 06e5660e3e..fcc9323add 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -236,6 +236,22 @@ test('should keep selected action in view after Show all', async ({ runAndTrace,await expect(selected).toBeInViewport();});+test('should activate Show all with keyboard', async ({ runAndTrace, page }) => {+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42323' });+ const traceViewer = await runAndTrace(async () => {+ await page.setContent('<div>hello</div>');+ await page.evaluate(x => x, 1);+ });++ await traceViewer.actionsTree.getByRole('treeitem').filter({ hasText: 'Evaluate' }).dblclick();++ const showAll = traceViewer.page.getByRole('button', { name: 'Show all' });+ await showAll.focus();+ await expect(showAll).toBeFocused();+ await showAll.press('Enter');+ await expect(showAll).toBeHidden();+});+test('should open uncompressed trace directory', async ({ showTraceViewer }) => {const traceDir = test.info().outputPath('unzipped-trace');await extractZip(traceFile, { dir: traceDir });@@ -397,6 +413,18 @@ test('should open console errors on click', async ({ showTraceViewer }) => {await traceViewer.page.getByRole('tabpanel', { name: 'Console' }).waitFor();});+test('should open console errors with keyboard', async ({ showTraceViewer }) => {+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42323' });+ const traceViewer = await showTraceViewer(traceFile);+ const badge = traceViewer.actionIcons('Evaluate');+ await expect(badge).toHaveAccessibleName('Reveal console, 2 errors, 1 warning');+ await badge.focus();+ await expect(badge).toBeFocused();+ await expect(traceViewer.page.getByRole('tabpanel', { name: 'Console' })).toBeHidden();+ await badge.press('Enter');+ await traceViewer.page.getByRole('tabpanel', { name: 'Console' }).waitFor();+});+test('should show params and return value', async ({ showTraceViewer }) => {const traceViewer = await showTraceViewer(traceFile);await traceViewer.selectAction('Evaluate');