From 0c3f60e95e2a174d511c86b07f9c1647b1700f6c Mon Sep 17 00:00:00 2001 From: Sarkis Matinyan Date: Wed, 6 Mar 2024 12:29:35 -0800 Subject: [PATCH] fix(ui): show stack frames in ui mode (#29560) #29558, #29500 --- packages/trace-viewer/src/ui/sourceTab.tsx | 8 +++-- packages/trace-viewer/src/ui/uiModeView.tsx | 1 - packages/trace-viewer/src/ui/workbench.tsx | 5 ++- tests/playwright-test/reporter-html.spec.ts | 35 ++++++++++++++++++++- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/packages/trace-viewer/src/ui/sourceTab.tsx b/packages/trace-viewer/src/ui/sourceTab.tsx index aebbbd872f..a3acad64a2 100644 --- a/packages/trace-viewer/src/ui/sourceTab.tsx +++ b/packages/trace-viewer/src/ui/sourceTab.tsx @@ -26,11 +26,11 @@ import type { StackFrame } from '@protocol/channels'; export const SourceTab: React.FunctionComponent<{ stack: StackFrame[] | undefined, + stackFrameLocation: 'bottom' | 'right', sources: Map, - hideStackFrames?: boolean, rootDir?: string, fallbackLocation?: SourceLocation, -}> = ({ stack, sources, hideStackFrames, rootDir, fallbackLocation }) => { +}> = ({ stack, sources, rootDir, fallbackLocation, stackFrameLocation }) => { const [lastStack, setLastStack] = React.useState(); const [selectedFrame, setSelectedFrame] = React.useState(0); @@ -78,7 +78,9 @@ export const SourceTab: React.FunctionComponent<{ return { source, highlight, targetLine, fileName }; }, [stack, selectedFrame, rootDir, fallbackLocation], { source: { errors: [], content: 'Loading\u2026' }, highlight: [] }); - return + const showStackFrames = (stack?.length ?? 0) > 1; + + return
{fileName &&
{fileName}
} diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 164167f272..c7406fb49f 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -589,7 +589,6 @@ const TraceView: React.FC<{ return void, isLive?: boolean, status?: UITestStatus, -}> = ({ model, hideStackFrames, showSourcesFirst, rootDir, fallbackLocation, initialSelection, onSelectionChanged, isLive, status }) => { +}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, initialSelection, onSelectionChanged, isLive, status }) => { const [selectedAction, setSelectedActionImpl] = React.useState(undefined); const [revealedStack, setRevealedStack] = React.useState(undefined); const [highlightedAction, setHighlightedAction] = React.useState(); @@ -158,8 +157,8 @@ export const Workbench: React.FunctionComponent<{ render: () => }; const consoleTab: TabbedPaneTabModel = { diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index 84f37be292..d6a07a47a3 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -442,8 +442,11 @@ for (const useIntermediateMergeReport of [false, true] as const) { `, 'a.test.js': ` import { test, expect } from '@playwright/test'; + async function evaluateWrapper(page, expression) { + await page.evaluate(expression); + } test('passes', async ({ page }) => { - await page.evaluate('2 + 2'); + await evaluateWrapper(page, '2 + 2'); }); `, }, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' }); @@ -468,6 +471,36 @@ for (const useIntermediateMergeReport of [false, true] as const) { await expect(page.getByTestId('stack-trace-list').locator('.list-view-entry.selected')).toContainText('a.test.js'); }); + test('should not show stack trace', async ({ runInlineTest, page, showReport }) => { + const result = await runInlineTest({ + 'playwright.config.js': ` + module.exports = { use: { trace: 'on' } }; + `, + 'a.test.js': ` + import { test, expect } from '@playwright/test'; + test('passes', async ({ page }) => { + await page.evaluate('2 + 2'); + }); + `, + }, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' }); + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); + + await showReport(); + await page.click('text=passes'); + await page.click('img'); + await page.click('.action-title >> text=page.evaluate'); + await page.click('text=Source'); + + await expect(page.locator('.CodeMirror-line')).toContainText([ + /import.*test/, + /page\.evaluate/ + ]); + await expect(page.locator('.source-line-running')).toContainText('page.evaluate'); + + await expect(page.getByTestId('stack-trace-list')).toHaveCount(0); + }); + test('should show trace title', async ({ runInlineTest, page, showReport }) => { const result = await runInlineTest({ 'playwright.config.js': `