diff --git a/packages/html-reporter/build.js b/packages/html-reporter/build.js deleted file mode 100644 index 20719c4e5e..0000000000 --- a/packages/html-reporter/build.js +++ /dev/null @@ -1,2 +0,0 @@ -// write something to playwright-core/lib/web/ with webpack - diff --git a/packages/playwright-core/src/web/htmlReport/bundleJsPlugin.js b/packages/html-reporter/bundleJsPlugin.js similarity index 100% rename from packages/playwright-core/src/web/htmlReport/bundleJsPlugin.js rename to packages/html-reporter/bundleJsPlugin.js diff --git a/packages/playwright-core/src/web/htmlReport/chip.css b/packages/html-reporter/src/chip.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/chip.css rename to packages/html-reporter/src/chip.css diff --git a/packages/playwright-core/src/web/htmlReport/chip.tsx b/packages/html-reporter/src/chip.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/chip.tsx rename to packages/html-reporter/src/chip.tsx diff --git a/packages/playwright-core/src/web/htmlReport/colors.css b/packages/html-reporter/src/colors.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/colors.css rename to packages/html-reporter/src/colors.css diff --git a/packages/playwright-core/src/web/htmlReport/common.css b/packages/html-reporter/src/common.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/common.css rename to packages/html-reporter/src/common.css diff --git a/packages/playwright-core/src/web/htmlReport/filter.ts b/packages/html-reporter/src/filter.ts similarity index 100% rename from packages/playwright-core/src/web/htmlReport/filter.ts rename to packages/html-reporter/src/filter.ts diff --git a/packages/playwright-core/src/web/htmlReport/headerView.tsx b/packages/html-reporter/src/headerView.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/headerView.tsx rename to packages/html-reporter/src/headerView.tsx diff --git a/packages/playwright-core/src/web/htmlReport/icons.tsx b/packages/html-reporter/src/icons.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/icons.tsx rename to packages/html-reporter/src/icons.tsx diff --git a/packages/playwright-core/src/web/htmlReport/images.ts b/packages/html-reporter/src/images.ts similarity index 100% rename from packages/playwright-core/src/web/htmlReport/images.ts rename to packages/html-reporter/src/images.ts diff --git a/packages/playwright-core/src/web/htmlReport/index.html b/packages/html-reporter/src/index.html similarity index 100% rename from packages/playwright-core/src/web/htmlReport/index.html rename to packages/html-reporter/src/index.html diff --git a/packages/playwright-core/src/web/htmlReport/index.tsx b/packages/html-reporter/src/index.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/index.tsx rename to packages/html-reporter/src/index.tsx diff --git a/packages/playwright-core/src/web/htmlReport/links.css b/packages/html-reporter/src/links.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/links.css rename to packages/html-reporter/src/links.css diff --git a/packages/playwright-core/src/web/htmlReport/links.tsx b/packages/html-reporter/src/links.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/links.tsx rename to packages/html-reporter/src/links.tsx diff --git a/packages/playwright-core/src/web/htmlReport/loadedReport.ts b/packages/html-reporter/src/loadedReport.ts similarity index 100% rename from packages/playwright-core/src/web/htmlReport/loadedReport.ts rename to packages/html-reporter/src/loadedReport.ts diff --git a/packages/playwright-core/src/web/htmlReport/reportView.css b/packages/html-reporter/src/reportView.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/reportView.css rename to packages/html-reporter/src/reportView.css diff --git a/packages/playwright-core/src/web/htmlReport/reportView.tsx b/packages/html-reporter/src/reportView.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/reportView.tsx rename to packages/html-reporter/src/reportView.tsx diff --git a/packages/playwright-core/src/web/htmlReport/statusIcon.tsx b/packages/html-reporter/src/statusIcon.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/statusIcon.tsx rename to packages/html-reporter/src/statusIcon.tsx diff --git a/packages/playwright-core/src/web/htmlReport/tabbedPane.css b/packages/html-reporter/src/tabbedPane.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/tabbedPane.css rename to packages/html-reporter/src/tabbedPane.css diff --git a/packages/playwright-core/src/web/htmlReport/tabbedPane.tsx b/packages/html-reporter/src/tabbedPane.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/tabbedPane.tsx rename to packages/html-reporter/src/tabbedPane.tsx diff --git a/packages/playwright-core/src/web/htmlReport/testCaseView.css b/packages/html-reporter/src/testCaseView.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/testCaseView.css rename to packages/html-reporter/src/testCaseView.css diff --git a/packages/playwright-core/src/web/htmlReport/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/testCaseView.tsx rename to packages/html-reporter/src/testCaseView.tsx diff --git a/packages/playwright-core/src/web/htmlReport/testFileView.css b/packages/html-reporter/src/testFileView.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/testFileView.css rename to packages/html-reporter/src/testFileView.css diff --git a/packages/playwright-core/src/web/htmlReport/testFileView.tsx b/packages/html-reporter/src/testFileView.tsx similarity index 98% rename from packages/playwright-core/src/web/htmlReport/testFileView.tsx rename to packages/html-reporter/src/testFileView.tsx index d50d09c008..cf55ca1450 100644 --- a/packages/playwright-core/src/web/htmlReport/testFileView.tsx +++ b/packages/html-reporter/src/testFileView.tsx @@ -16,7 +16,7 @@ import type { HTMLReport, TestFileSummary } from '@playwright/test/src/reporters/html'; import * as React from 'react'; -import { msToString } from '../uiUtils'; +import { msToString } from './uiUtils'; import { Chip } from './chip'; import { Filter } from './filter'; import { Link, ProjectLink } from './links'; diff --git a/packages/playwright-core/src/web/htmlReport/testFilesView.tsx b/packages/html-reporter/src/testFilesView.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/testFilesView.tsx rename to packages/html-reporter/src/testFilesView.tsx diff --git a/packages/playwright-core/src/web/htmlReport/testResultView.css b/packages/html-reporter/src/testResultView.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/testResultView.css rename to packages/html-reporter/src/testResultView.css diff --git a/packages/playwright-core/src/web/htmlReport/testResultView.tsx b/packages/html-reporter/src/testResultView.tsx similarity index 99% rename from packages/playwright-core/src/web/htmlReport/testResultView.tsx rename to packages/html-reporter/src/testResultView.tsx index 175e218840..f859cb2db6 100644 --- a/packages/playwright-core/src/web/htmlReport/testResultView.tsx +++ b/packages/html-reporter/src/testResultView.tsx @@ -19,7 +19,7 @@ import ansi2html from 'ansi-to-html'; import * as React from 'react'; import { TreeItem } from './treeItem'; import { TabbedPane } from './tabbedPane'; -import { msToString } from '../uiUtils'; +import { msToString } from './uiUtils'; import { Chip } from './chip'; import { traceImage } from './images'; import { AttachmentLink } from './links'; diff --git a/packages/playwright-core/src/web/htmlReport/treeItem.css b/packages/html-reporter/src/treeItem.css similarity index 100% rename from packages/playwright-core/src/web/htmlReport/treeItem.css rename to packages/html-reporter/src/treeItem.css diff --git a/packages/playwright-core/src/web/htmlReport/treeItem.tsx b/packages/html-reporter/src/treeItem.tsx similarity index 100% rename from packages/playwright-core/src/web/htmlReport/treeItem.tsx rename to packages/html-reporter/src/treeItem.tsx diff --git a/packages/html-reporter/src/uiUtils.ts b/packages/html-reporter/src/uiUtils.ts new file mode 100644 index 0000000000..34ad57731f --- /dev/null +++ b/packages/html-reporter/src/uiUtils.ts @@ -0,0 +1,41 @@ +/* + Copyright (c) Microsoft Corporation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +export function msToString(ms: number): string { + if (!isFinite(ms)) + return '-'; + + if (ms === 0) + return '0'; + + if (ms < 1000) + return ms.toFixed(0) + 'ms'; + + const seconds = ms / 1000; + if (seconds < 60) + return seconds.toFixed(1) + 's'; + + const minutes = seconds / 60; + if (minutes < 60) + return minutes.toFixed(1) + 'm'; + + const hours = minutes / 60; + if (hours < 24) + return hours.toFixed(1) + 'h'; + + const days = hours / 24; + return days.toFixed(1) + 'd'; +} diff --git a/packages/playwright-core/src/web/htmlReport/webpack.config.js b/packages/html-reporter/webpack.config.js similarity index 84% rename from packages/playwright-core/src/web/htmlReport/webpack.config.js rename to packages/html-reporter/webpack.config.js index 7f8e0606b5..059d769852 100644 --- a/packages/playwright-core/src/web/htmlReport/webpack.config.js +++ b/packages/html-reporter/webpack.config.js @@ -23,8 +23,8 @@ const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development module.exports = { mode, entry: { - zip: path.resolve(__dirname, '../../../../../node_modules/@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'), - app: path.join(__dirname, 'index.tsx'), + zip: require.resolve('@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'), + app: path.join(__dirname, 'src', 'index.tsx'), }, resolve: { extensions: ['.ts', '.js', '.tsx', '.jsx'] @@ -33,7 +33,7 @@ module.exports = { output: { globalObject: 'self', filename: '[name].bundle.js', - path: path.resolve(__dirname, '../../../lib/webpack/htmlReport') + path: path.resolve(__dirname, '..', 'playwright-core', 'lib', 'webpack', 'htmlReport') }, module: { rules: [ @@ -57,7 +57,7 @@ module.exports = { plugins: [ new HtmlWebPackPlugin({ title: 'Playwright Test Report', - template: path.join(__dirname, 'index.html'), + template: path.join(__dirname, 'src', 'index.html'), inject: true, }), new BundleJsPlugin(), diff --git a/utils/build/build.js b/utils/build/build.js index 3213cf87ea..4737907a43 100644 --- a/utils/build/build.js +++ b/utils/build/build.js @@ -159,7 +159,7 @@ const webPackFiles = [ 'packages/playwright-core/src/web/traceViewer/webpack.config.js', 'packages/playwright-core/src/web/traceViewer/webpack-sw.config.js', 'packages/playwright-core/src/web/recorder/webpack.config.js', - 'packages/playwright-core/src/web/htmlReport/webpack.config.js', + 'packages/html-reporter/webpack.config.js', ]; for (const file of webPackFiles) { steps.push({ diff --git a/utils/check_deps.js b/utils/check_deps.js index 9d563e1021..9a8ad6d6c0 100644 --- a/utils/check_deps.js +++ b/utils/check_deps.js @@ -238,12 +238,6 @@ DEPS['src/server/trace/viewer/'] = ['src/server/trace/common/', 'src/server/trac // DEPS['src/test/'] = ['src/test/**', 'src/utils/utils.ts', 'src/utils/**', 'src/protocol/channels.ts']; // DEPS['src/test/index.ts'] = [... DEPS['src/test/'], 'src/grid/gridClient.ts' ]; -// HTML report -DEPS['src/web/htmlReport/'] = [ - // 'src/test/**', - 'src/web/' -]; - // Grid DEPS['src/grid/'] = ['src/utils/**', 'src/dispatchers/**', 'src/server/', 'src/client/'];