From 432fb453e45cdd095a9083582e90fe49a22bfa84 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 18 Oct 2021 07:03:04 -0800 Subject: [PATCH] chore(html): only copy trace viewer for reports with traces (#9579) --- .../src/web/components/treeItem.tsx | 16 ++++-- .../src/web/htmlReport/htmlReport.css | 51 +++++++++++++++--- .../src/web/htmlReport/htmlReport.tsx | 31 +++++++---- .../playwright-test/src/reporters/html.ts | 52 ++++++++++++++----- tests/playwright-test/reporter-html.spec.ts | 11 +++- 5 files changed, 124 insertions(+), 37 deletions(-) diff --git a/packages/playwright-core/src/web/components/treeItem.tsx b/packages/playwright-core/src/web/components/treeItem.tsx index 354bfb70d0..b48b83a2ea 100644 --- a/packages/playwright-core/src/web/components/treeItem.tsx +++ b/packages/playwright-core/src/web/components/treeItem.tsx @@ -26,12 +26,18 @@ export const TreeItem: React.FunctionComponent<{ }> = ({ title, loadChildren, onClick, expandByDefault, depth, selected }) => { const [expanded, setExpanded] = React.useState(expandByDefault || false); const className = selected ? 'tree-item-title selected' : 'tree-item-title'; - return
-
{ onClick?.(); setExpanded(!expanded); }} > -
+ return
+ { onClick?.(); setExpanded(!expanded); }} > + {title} -
+ {expanded && loadChildren?.()}
; }; diff --git a/packages/playwright-core/src/web/htmlReport/htmlReport.css b/packages/playwright-core/src/web/htmlReport/htmlReport.css index 7fa3b044ff..657878ee87 100644 --- a/packages/playwright-core/src/web/htmlReport/htmlReport.css +++ b/packages/playwright-core/src/web/htmlReport/htmlReport.css @@ -34,6 +34,12 @@ body { overflow: auto; } +.global-stats { + padding-left: 34px; + margin-top: 20px; + font-weight: 600; +} + .suite-tree-column { line-height: 18px; flex: auto; @@ -47,11 +53,21 @@ body { margin: 20px; } +.tree-item { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + .tree-item-title { - padding: 8px 8px 8px 0; cursor: pointer; } +.chip-body .tree-item { + max-width: 600px; + line-height: 38px; +} + .tree-item-body { min-height: 18px; } @@ -159,6 +175,7 @@ body { } .test-case-column .tab-strip { + margin-top: 10px; background-color: inherit; } @@ -223,18 +240,21 @@ body { video, img { flex: none; box-shadow: var(--box-shadow-thick); - width: 80%; margin: 20px auto; - min-width: 80%; - min-height: 300px; + min-width: 200px; + max-width: 80%; } .flow-container { - max-width: 1280px; + max-width: 1024px; margin: 0 auto; width: 100%; } +.file-summary-list { + padding-bottom: 20px; +} + .file-summary-list .chip-body a:not(:nth-child(1)) .test-summary, .failed-test:not(:nth-child(1)) { border-top: 1px solid var(--color-border-default); @@ -274,16 +294,18 @@ a.no-decorations { } .chip-header { - display: flex; - align-items: center; border: 1px solid var(--color-border-default); border-top-left-radius: 6px; border-top-right-radius: 6px; background-color: var(--color-page-header-bg); - padding: 10px; + padding: 0 10px; border-bottom: none; margin-top: 20px; font-weight: 600; + line-height: 38px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .chip-header.expanded-false { @@ -296,6 +318,11 @@ a.no-decorations { cursor: pointer; } +.chip-header .codicon { + position: relative; + top: 3px; +} + .chip-body { border: 1px solid var(--color-border-default); border-bottom-left-radius: 6px; @@ -331,6 +358,10 @@ a.no-decorations { color: var(--color-fg-muted); } +.test-summary.outcome-skipped { + color: var(--color-fg-muted); +} + .octicon { display: inline-block; overflow: visible !important; @@ -354,6 +385,10 @@ a.no-decorations { color: var(--color-fg-muted) !important; } +.color-fg-white { + color: white !important; +} + .octicon { margin-right: 7px; flex: none; diff --git a/packages/playwright-core/src/web/htmlReport/htmlReport.tsx b/packages/playwright-core/src/web/htmlReport/htmlReport.tsx index 26853de0a5..c8158fba7e 100644 --- a/packages/playwright-core/src/web/htmlReport/htmlReport.tsx +++ b/packages/playwright-core/src/web/htmlReport/htmlReport.tsx @@ -67,6 +67,10 @@ const AllTestFilesSummaryView: React.FC<{ setFileExpanded: (fileId: string, expanded: boolean) => void; }> = ({ report, isFileExpanded, setFileExpanded }) => { return
+ {report &&
+ Ran {report.stats.total} tests + +
} {report && (report.files || []).map((file, i) => )}
; }; @@ -77,13 +81,21 @@ const TestFileSummaryView: React.FC<{ isFileExpanded: (fileId: string) => boolean; setFileExpanded: (fileId: string, expanded: boolean) => void; }> = ({ file, report, isFileExpanded, setFileExpanded }) => { - return setFileExpanded(file.fileId, expanded))} header={{file.fileName}}> + return setFileExpanded(file.fileId, expanded))} + header={ + {file.fileName} + + {msToString(file.stats.duration)} + }> {file.tests.map((test, i) => -
- {test.projectName} +
{statusIcon(test.outcome)} {test.title} — {test.path.join(' › ')} + {report.projectNames.length > 1 && !!test.projectName && {test.projectName}} + {msToString(test.duration)}
)} ; @@ -116,7 +128,7 @@ const TestCaseView: React.FC<{ return
{test &&
{test?.title}
} {test &&
{test.path.join(' › ')}
} - {test &&
{test.projectName}
} + {test && !!test.projectName &&
{test.projectName}
} {test && ({ id: String(index), @@ -201,12 +213,11 @@ const StepTreeItem: React.FC<{ step: TestStep; depth: number, }> = ({ step, depth }) => { - return + return + {msToString(step.duration)} {statusIcon(step.error ? 'failed' : 'passed')} - {step.title} -
-
{msToString(step.duration)}
-
} loadChildren={step.steps.length + (step.error ? 1 : 0) ? () => { + {step.title} + } loadChildren={step.steps.length + (step.error ? 1 : 0) ? () => { const children = step.steps.map((s, i) => ); if (step.error) children.unshift(); @@ -287,7 +298,7 @@ function statusIcon(status: 'failed' | 'timedOut' | 'skipped' | 'passed' | 'expe ; case 'skipped': - return