From 37b2853b7b8ef031bb06e72ea382d794053c4e6d Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 16 May 2023 12:47:37 -0700 Subject: [PATCH] chore: fix the test view mobile layout (#23061) Fixes https://github.com/microsoft/playwright/issues/23036 --- packages/html-reporter/src/chip.css | 1 - .../html-reporter/src/headerView.spec.tsx | 50 ------------------- packages/html-reporter/src/headerView.tsx | 8 +-- .../html-reporter/src/imageDiffView.spec.tsx | 6 +-- packages/html-reporter/src/reportView.tsx | 11 +++- packages/html-reporter/src/tabbedPane.css | 1 + packages/html-reporter/src/testCaseView.css | 3 +- packages/html-reporter/src/testCaseView.tsx | 7 ++- packages/html-reporter/src/testFilesView.tsx | 10 +++- 9 files changed, 31 insertions(+), 66 deletions(-) diff --git a/packages/html-reporter/src/chip.css b/packages/html-reporter/src/chip.css index f8d7938f90..c2bf103bfa 100644 --- a/packages/html-reporter/src/chip.css +++ b/packages/html-reporter/src/chip.css @@ -21,7 +21,6 @@ background-color: var(--color-canvas-subtle); padding: 0 8px; border-bottom: none; - margin-top: 24px; font-weight: 600; line-height: 38px; white-space: nowrap; diff --git a/packages/html-reporter/src/headerView.spec.tsx b/packages/html-reporter/src/headerView.spec.tsx index 733df21b6b..5c05ec1e29 100644 --- a/packages/html-reporter/src/headerView.spec.tsx +++ b/packages/html-reporter/src/headerView.spec.tsx @@ -50,7 +50,6 @@ test('should toggle filters', async ({ page, mount }) => { }} filterText='' setFilterText={(filterText: string) => filters.push(filterText)} - projectNames={[]} > ); await component.locator('a', { hasText: 'All' }).click(); @@ -64,52 +63,3 @@ test('should toggle filters', async ({ page, mount }) => { await expect(page).toHaveURL(/#\?q=s:skipped/); expect(filters).toEqual(['', 's:passed', 's:failed', 's:flaky', 's:skipped']); }); - -test('should show the project names', async ({ mount }) => { - const stats = { - total: 100, - expected: 42, - unexpected: 31, - flaky: 17, - skipped: 10, - ok: false, - duration: 100000 - }; - await test.step('with 1 project', async () => { - const component = await mount( {}} - projectNames={['my-project']} - > - ); - await expect(component.getByText('Project: my-project')).toBeVisible(); - - await component.unmount(); - }); - await test.step('with 1 project and empty projectName', async () => { - const component = await mount( {}} - projectNames={['']} - > - ); - await expect(component.getByText('Project:')).toBeHidden(); - - await component.unmount(); - }); - await test.step('with more than 1 project', async () => { - const component = await mount( {}} - projectNames={['great-project', 'my-project']} - > - ); - await expect(component.getByText('my-project')).toBeHidden(); - await expect(component.getByText('great-project')).toBeHidden(); - - await component.unmount(); - }); -}); diff --git a/packages/html-reporter/src/headerView.tsx b/packages/html-reporter/src/headerView.tsx index 11c9a2d724..3c24ace4c0 100644 --- a/packages/html-reporter/src/headerView.tsx +++ b/packages/html-reporter/src/headerView.tsx @@ -22,14 +22,12 @@ import './headerView.css'; import * as icons from './icons'; import { Link, navigate } from './links'; import { statusIcon } from './statusIcon'; -import { msToString } from './uiUtils'; export const HeaderView: React.FC void, - projectNames: string[], -}>> = ({ stats, filterText, setFilterText, projectNames }) => { +}>> = ({ stats, filterText, setFilterText }) => { React.useEffect(() => { const popstateFn = () => { const params = new URLSearchParams(window.location.hash.slice(1)); @@ -60,10 +58,6 @@ export const HeaderView: React.FC -
- {projectNames.length === 1 && !!projectNames[0] && Project: {projectNames[0]}} - Total time: {msToString(stats.duration)} -
); }; diff --git a/packages/html-reporter/src/imageDiffView.spec.tsx b/packages/html-reporter/src/imageDiffView.spec.tsx index d2339919b0..53ffce0c1b 100644 --- a/packages/html-reporter/src/imageDiffView.spec.tsx +++ b/packages/html-reporter/src/imageDiffView.spec.tsx @@ -55,7 +55,7 @@ test('should switch to actual', async ({ mount }) => { for (let i = 0; i < imageCount; ++i) { const image = images.nth(i); const box = await image.boundingBox(); - expect(box).toEqual({ x: 400, y: 108, width: 200, height: 200 }); + expect(box).toEqual({ x: 400, y: 124, width: 200, height: 200 }); } }); @@ -70,7 +70,7 @@ test('should switch to expected', async ({ mount }) => { for (let i = 0; i < imageCount; ++i) { const image = images.nth(i); const box = await image.boundingBox(); - expect(box).toEqual({ x: 400, y: 108, width: 200, height: 200 }); + expect(box).toEqual({ x: 400, y: 124, width: 200, height: 200 }); } }); @@ -79,5 +79,5 @@ test('should show diff by default', async ({ mount }) => { const image = component.locator('img'); const box = await image.boundingBox(); - expect(box).toEqual({ x: 400, y: 108, width: 200, height: 200 }); + expect(box).toEqual({ x: 400, y: 124, width: 200, height: 200 }); }); diff --git a/packages/html-reporter/src/reportView.tsx b/packages/html-reporter/src/reportView.tsx index 08dd0e11e9..1b25de38e0 100644 --- a/packages/html-reporter/src/reportView.tsx +++ b/packages/html-reporter/src/reportView.tsx @@ -50,10 +50,17 @@ export const ReportView: React.FC<{ return
- {report?.json() && } + {report?.json() && } {report?.json().metadata && } - + {!!report && } diff --git a/packages/html-reporter/src/tabbedPane.css b/packages/html-reporter/src/tabbedPane.css index 7a128da217..e939859a79 100644 --- a/packages/html-reporter/src/tabbedPane.css +++ b/packages/html-reporter/src/tabbedPane.css @@ -33,6 +33,7 @@ height: 48px; min-width: 70px; box-shadow: inset 0 -1px 0 var(--color-border-muted) !important; + margin-bottom: 16px; } .tabbed-pane-tab-strip:focus { diff --git a/packages/html-reporter/src/testCaseView.css b/packages/html-reporter/src/testCaseView.css index ae2568977e..81b2b16ed1 100644 --- a/packages/html-reporter/src/testCaseView.css +++ b/packages/html-reporter/src/testCaseView.css @@ -42,7 +42,8 @@ line-height: 1.25 !important; } -.test-case-location { +.test-case-location, +.test-case-duration { flex: none; align-items: center; padding: 0 8px 24px; diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx index f67de95b3a..d40e1e871a 100644 --- a/packages/html-reporter/src/testCaseView.tsx +++ b/packages/html-reporter/src/testCaseView.tsx @@ -24,6 +24,7 @@ import { statusIcon } from './statusIcon'; import './testCaseView.css'; import { TestResultView } from './testResultView'; import { hashStringToInt, matchTags } from './labelUtils'; +import { msToString } from './uiUtils'; export const TestCaseView: React.FC<{ projectNames: string[], @@ -42,7 +43,11 @@ export const TestCaseView: React.FC<{ return
{test &&
{test.path.join(' › ')}
} {test &&
{test?.title}
} - {test &&
{test.location.file}:{test.location.line}
} + {test &&
+
{test.location.file}:{test.location.line}
+
+
{msToString(test.duration)}
+
} {test && (!!test.projectName || labels) &&
{test && !!test.projectName && } {labels && } diff --git a/packages/html-reporter/src/testFilesView.tsx b/packages/html-reporter/src/testFilesView.tsx index 0dc1af4e93..447b9d7601 100644 --- a/packages/html-reporter/src/testFilesView.tsx +++ b/packages/html-reporter/src/testFilesView.tsx @@ -19,13 +19,16 @@ import * as React from 'react'; import type { Filter } from './filter'; import { TestFileView } from './testFileView'; import './testFileView.css'; +import { msToString } from './uiUtils'; export const TestFilesView: React.FC<{ report?: HTMLReport, expandedFiles: Map, setExpandedFiles: (value: Map) => void, filter: Filter, -}> = ({ report, filter, expandedFiles, setExpandedFiles }) => { + stats: { duration: number }, + projectNames: string[], +}> = ({ report, filter, expandedFiles, setExpandedFiles, projectNames, stats }) => { const filteredFiles = React.useMemo(() => { const result: { file: TestFileSummary, defaultExpanded: boolean }[] = []; let visibleTests = 0; @@ -38,6 +41,11 @@ export const TestFilesView: React.FC<{ return result; }, [report, filter]); return <> +
+ {projectNames.length === 1 && !!projectNames[0] &&
Project: {projectNames[0]}
} +
+
Total time: {msToString(stats.duration)}
+
{report && filteredFiles.map(({ file, defaultExpanded }) => { return