diff --git a/packages/html-reporter/src/testFileView.tsx b/packages/html-reporter/src/testFileView.tsx
index bd402a74de..4d6890ad33 100644
--- a/packages/html-reporter/src/testFileView.tsx
+++ b/packages/html-reporter/src/testFileView.tsx
@@ -14,24 +14,25 @@
limitations under the License.
*/
-import type { HTMLReport, TestCaseSummary, TestFileSummary } from './types';
+import type { TestCaseSummary, TestFileSummary } from './types';
import * as React from 'react';
import { hashStringToInt, msToString } from './utils';
import { Chip } from './chip';
-import { filterWithToken, type Filter } from './filter';
-import { generateTraceUrl, Link, navigate, ProjectLink } from './links';
+import { filterWithToken } from './filter';
+import { generateTraceUrl, Link, navigate, ProjectLink, SearchParamsContext } from './links';
import { statusIcon } from './statusIcon';
import './testFileView.css';
import { video, image, trace } from './icons';
import { clsx } from '@web/uiUtils';
export const TestFileView: React.FC
boolean;
setFileExpanded: (fileId: string, expanded: boolean) => void;
- filter: Filter;
-}>> = ({ file, report, isFileExpanded, setFileExpanded, filter }) => {
+}>> = ({ file, projectNames, isFileExpanded, setFileExpanded }) => {
+ const searchParams = React.useContext(SearchParamsContext);
+ const filterParam = searchParams.has('q') ? '&q=' + searchParams.get('q') : '';
return
{file.fileName}
}>
- {file.tests.filter(t => filter.matches(t)).map(test =>
+ {file.tests.map(test =>
@@ -47,11 +48,11 @@ export const TestFileView: React.FC
-
+
{[...test.path, test.title].join(' › ')}
- {report.projectNames.length > 1 && !!test.projectName &&
- }
+ {projectNames.length > 1 && !!test.projectName &&
+ }
@@ -90,10 +91,10 @@ function traceBadge(test: TestCaseSummary): JSX.Element | undefined {
const LabelsClickView: React.FC
> = ({ labels }) => {
+ const searchParams = React.useContext(SearchParamsContext);
const onClickHandle = (e: React.MouseEvent, label: string) => {
e.preventDefault();
- const searchParams = new URLSearchParams(window.location.hash.slice(1));
const q = searchParams.get('q')?.toString() || '';
const tokens = q.split(' ');
navigate(filterWithToken(tokens, label, e.metaKey || e.ctrlKey));
diff --git a/packages/html-reporter/src/testFilesView.tsx b/packages/html-reporter/src/testFilesView.tsx
index 30c80c075b..d21088f575 100644
--- a/packages/html-reporter/src/testFilesView.tsx
+++ b/packages/html-reporter/src/testFilesView.tsx
@@ -16,7 +16,6 @@
import type { FilteredStats, HTMLReport, TestFileSummary } from './types';
import * as React from 'react';
-import type { Filter } from './filter';
import { TestFileView } from './testFileView';
import './testFileView.css';
import { msToString } from './utils';
@@ -24,40 +23,26 @@ import { AutoChip } from './chip';
import { TestErrorView } from './testErrorView';
export const TestFilesView: React.FC<{
- report?: HTMLReport,
+ tests: TestFileSummary[],
expandedFiles: Map,
setExpandedFiles: (value: Map) => void,
- filter: Filter,
- filteredStats: FilteredStats,
projectNames: string[],
-}> = ({ report, filter, expandedFiles, setExpandedFiles, projectNames, filteredStats }) => {
+}> = ({ tests, expandedFiles, setExpandedFiles, projectNames }) => {
const filteredFiles = React.useMemo(() => {
const result: { file: TestFileSummary, defaultExpanded: boolean }[] = [];
let visibleTests = 0;
- for (const file of report?.files || []) {
- const tests = file.tests.filter(t => filter.matches(t));
- visibleTests += tests.length;
- if (tests.length)
- result.push({ file, defaultExpanded: visibleTests < 200 });
+ for (const file of tests) {
+ visibleTests += file.tests.length;
+ result.push({ file, defaultExpanded: visibleTests < 200 });
}
return result;
- }, [report, filter]);
+ }, [tests]);
return <>
-
- {projectNames.length === 1 && !!projectNames[0] &&
Project: {projectNames[0]}
}
- {!filter.empty() &&
Filtered: {filteredStats.total} {!!filteredStats.total && ('(' + msToString(filteredStats.duration) + ')')}
}
-
-
{report ? new Date(report.startTime).toLocaleString() : ''}
-
Total time: {msToString(report?.duration ?? 0)}
-
- {report && !!report.errors.length &&
- {report.errors.map((error, index) => )}
- }
- {report && filteredFiles.map(({ file, defaultExpanded }) => {
+ {filteredFiles.map(({ file, defaultExpanded }) => {
return {
const value = expandedFiles.get(fileId);
if (value === undefined)
@@ -68,9 +53,28 @@ export const TestFilesView: React.FC<{
const newExpanded = new Map(expandedFiles);
newExpanded.set(fileId, expanded);
setExpandedFiles(newExpanded);
- }}
- filter={filter}>
+ }}>
;
})}
>;
};
+
+export const TestFilesHeader: React.FC<{
+ report: HTMLReport | undefined,
+ filteredStats?: FilteredStats,
+}> = ({ report, filteredStats }) => {
+ if (!report)
+ return;
+ return <>
+
+ {report.projectNames.length === 1 && !!report.projectNames[0] &&
Project: {report.projectNames[0]}
}
+ {filteredStats &&
Filtered: {filteredStats.total} {!!filteredStats.total && ('(' + msToString(filteredStats.duration) + ')')}
}
+
+
{report ? new Date(report.startTime).toLocaleString() : ''}
+
Total time: {msToString(report.duration ?? 0)}
+
+ {!!report.errors.length &&
+ {report.errors.map((error, index) => )}
+ }
+ >;
+};