From f166c67707c89157f9550b99fcf480f6280c84c0 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 13 Dec 2021 15:37:01 -0800 Subject: [PATCH] chore: more html reporter components (#10896) --- .../src/web/htmlReport/chip.tsx | 17 +- .../src/web/htmlReport/filter.ts | 1 - .../{statsNavView.tsx => headerView.tsx} | 40 +++- .../src/web/htmlReport/htmlReport.tsx | 192 ------------------ .../src/web/htmlReport/icons.tsx | 71 +++++++ .../src/web/htmlReport/index.tsx | 43 +++- .../src/web/htmlReport/links.tsx | 33 ++- .../src/web/htmlReport/loadedReport.ts | 22 ++ .../{htmlReport.css => reportView.css} | 2 +- .../src/web/htmlReport/reportView.tsx | 83 ++++++++ .../src/web/htmlReport/statusIcon.tsx | 23 +-- .../src/web/htmlReport/testFilesView.tsx | 61 ++++++ .../src/web/htmlReport/treeItem.tsx | 19 +- 13 files changed, 356 insertions(+), 251 deletions(-) rename packages/playwright-core/src/web/htmlReport/{statsNavView.tsx => headerView.tsx} (57%) delete mode 100644 packages/playwright-core/src/web/htmlReport/htmlReport.tsx create mode 100644 packages/playwright-core/src/web/htmlReport/icons.tsx create mode 100644 packages/playwright-core/src/web/htmlReport/loadedReport.ts rename packages/playwright-core/src/web/htmlReport/{htmlReport.css => reportView.css} (99%) create mode 100644 packages/playwright-core/src/web/htmlReport/reportView.tsx create mode 100644 packages/playwright-core/src/web/htmlReport/testFilesView.tsx diff --git a/packages/playwright-core/src/web/htmlReport/chip.tsx b/packages/playwright-core/src/web/htmlReport/chip.tsx index 2ca3811764..e05a96dd10 100644 --- a/packages/playwright-core/src/web/htmlReport/chip.tsx +++ b/packages/playwright-core/src/web/htmlReport/chip.tsx @@ -16,6 +16,7 @@ import * as React from 'react'; import './chip.css'; +import * as icons from './icons'; export const Chip: React.FunctionComponent<{ header: JSX.Element | string, @@ -26,22 +27,10 @@ export const Chip: React.FunctionComponent<{ }> = ({ header, expanded, setExpanded, children, noInsets }) => { return
setExpanded?.(!expanded)}> - {setExpanded && !!expanded && downArrow()} - {setExpanded && !expanded && rightArrow()} + {setExpanded && !!expanded && icons.downArrow()} + {setExpanded && !expanded && icons.rightArrow()} {header}
{(!setExpanded || expanded) &&
{children}
}
; }; - -function downArrow() { - return ; -} - -function rightArrow() { - return ; -} diff --git a/packages/playwright-core/src/web/htmlReport/filter.ts b/packages/playwright-core/src/web/htmlReport/filter.ts index ed0ff9ee95..66467eb2f8 100644 --- a/packages/playwright-core/src/web/htmlReport/filter.ts +++ b/packages/playwright-core/src/web/htmlReport/filter.ts @@ -15,7 +15,6 @@ */ import type { TestCaseSummary } from '@playwright/test/src/reporters/html'; -import './htmlReport.css'; export class Filter { project: string[] = []; diff --git a/packages/playwright-core/src/web/htmlReport/statsNavView.tsx b/packages/playwright-core/src/web/htmlReport/headerView.tsx similarity index 57% rename from packages/playwright-core/src/web/htmlReport/statsNavView.tsx rename to packages/playwright-core/src/web/htmlReport/headerView.tsx index d84381bb97..5e90e9a2f1 100644 --- a/packages/playwright-core/src/web/htmlReport/statsNavView.tsx +++ b/packages/playwright-core/src/web/htmlReport/headerView.tsx @@ -16,11 +16,45 @@ import type { Stats } from '@playwright/test/src/reporters/html'; import * as React from 'react'; -import './htmlReport.css'; -import { Link } from './links'; +import './common.css'; +import * as icons from './icons'; +import { Link, navigate } from './links'; import { statusIcon } from './statusIcon'; -export const StatsNavView: React.FC<{ +export const HeaderView: React.FC<{ + stats: Stats, + filterText: string, + setFilterText: (filterText: string) => void, +}> = ({ stats, filterText, setFilterText }) => { + React.useEffect(() => { + (async () => { + window.addEventListener('popstate', () => { + const params = new URLSearchParams(window.location.hash.slice(1)); + setFilterText(params.get('q') || ''); + }); + })(); + }); + + return
+
+ +
+
{ + event.preventDefault(); + navigate(`#?q=${filterText ? encodeURIComponent(filterText) : ''}`); + } + }> + {icons.search()} + {/* Use navigationId to reset defaultValue */} + { + setFilterText(e.target.value); + }}> +
+
; +}; + +const StatsNavView: React.FC<{ stats: Stats }> = ({ stats }) => { return