lighthouse 8.5.1-dev.20210928 → 8.5.1-dev.20211002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/flow-report/.eslintrc.cjs +49 -0
- package/flow-report/assets/styles.css +1 -0
- package/flow-report/jest.config.js +1 -1
- package/flow-report/package.json +4 -0
- package/flow-report/src/app.tsx +8 -5
- package/flow-report/src/header.tsx +5 -1
- package/flow-report/src/i18n/i18n.tsx +44 -0
- package/flow-report/src/i18n/localized-strings.js +11 -0
- package/flow-report/src/i18n/ui-strings.js +40 -0
- package/flow-report/src/sidebar/sidebar.tsx +10 -15
- package/flow-report/src/summary/category.tsx +21 -13
- package/flow-report/src/summary/summary.tsx +24 -10
- package/flow-report/src/topbar.tsx +4 -1
- package/flow-report/src/util.ts +7 -7
- package/flow-report/test/app-test.tsx +1 -12
- package/flow-report/test/header-test.tsx +7 -13
- package/flow-report/test/sample-flow.ts +17 -0
- package/flow-report/test/sidebar/flow-test.tsx +6 -12
- package/flow-report/test/sidebar/sidebar-test.tsx +7 -13
- package/flow-report/test/summary/category-test.tsx +22 -14
- package/flow-report/test/summary/summary-test.tsx +5 -13
- package/flow-report/test/util-test.tsx +1 -12
- package/flow-report/tsconfig.json +1 -0
- package/jest.config.js +0 -15
- package/lighthouse-core/fraggle-rock/api.js +10 -0
- package/lighthouse-core/fraggle-rock/user-flow.js +27 -3
- package/lighthouse-core/lib/i18n/i18n.js +13 -1
- package/lighthouse-core/lib/i18n/locales/en-US.json +45 -0
- package/lighthouse-core/lib/i18n/locales/en-XL.json +45 -0
- package/lighthouse-core/lib/i18n/swap-flow-locale.js +20 -0
- package/lighthouse-core/lib/stack-packs.js +1 -13
- package/package.json +11 -9
- package/readme.md +1 -1
- package/report/clients/psi.js +1 -0
- package/report/test/clients/psi-test.js +2 -3
- package/report/test/renderer/report-renderer-axe-test.js +86 -0
- package/report/test/renderer/report-renderer-test.js +0 -55
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +5 -3
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
extends: '../.eslintrc.js',
|
|
9
|
+
env: {
|
|
10
|
+
node: true,
|
|
11
|
+
browser: true,
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
'@typescript-eslint',
|
|
15
|
+
],
|
|
16
|
+
rules: {
|
|
17
|
+
// TODO(esmodules): move to root eslint when all code is ESM
|
|
18
|
+
// or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
|
|
19
|
+
'import/order': [2, {
|
|
20
|
+
'groups': [
|
|
21
|
+
'builtin',
|
|
22
|
+
'external',
|
|
23
|
+
['sibling', 'parent'],
|
|
24
|
+
'index',
|
|
25
|
+
'object',
|
|
26
|
+
'type',
|
|
27
|
+
],
|
|
28
|
+
'newlines-between': 'always',
|
|
29
|
+
}],
|
|
30
|
+
'@typescript-eslint/type-annotation-spacing': 2,
|
|
31
|
+
},
|
|
32
|
+
overrides: [
|
|
33
|
+
// TS already handles this issue.
|
|
34
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
35
|
+
{
|
|
36
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js'],
|
|
37
|
+
rules: {
|
|
38
|
+
'no-undef': 'off',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
parserOptions: {
|
|
43
|
+
ecmaVersion: 2019,
|
|
44
|
+
ecmaFeatures: {
|
|
45
|
+
jsx: true,
|
|
46
|
+
},
|
|
47
|
+
sourceType: 'module',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 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.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export default {
|
|
8
8
|
testEnvironment: 'node',
|
|
9
9
|
preset: 'ts-jest',
|
|
10
10
|
globalSetup: './test/setup/global-setup.ts',
|
package/flow-report/src/app.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import {classNames, FlowResultContext, useCurrentLhr, useHashParam} from './util
|
|
|
14
14
|
import {Report} from './wrappers/report';
|
|
15
15
|
import {Topbar} from './topbar';
|
|
16
16
|
import {Header} from './header';
|
|
17
|
+
import {I18nProvider} from './i18n/i18n';
|
|
17
18
|
|
|
18
19
|
const Content: FunctionComponent = () => {
|
|
19
20
|
const currentLhr = useCurrentLhr();
|
|
@@ -52,11 +53,13 @@ export const App: FunctionComponent<{flowResult: LH.FlowResult}> = ({flowResult}
|
|
|
52
53
|
return (
|
|
53
54
|
<FlowResultContext.Provider value={flowResult}>
|
|
54
55
|
<ReportRendererProvider>
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
<I18nProvider>
|
|
57
|
+
<div className={classNames('App', {'App--collapsed': collapsed})}>
|
|
58
|
+
<Topbar onMenuClick={() => setCollapsed(c => !c)} />
|
|
59
|
+
<Sidebar/>
|
|
60
|
+
<Content/>
|
|
61
|
+
</div>
|
|
62
|
+
</I18nProvider>
|
|
60
63
|
</ReportRendererProvider>
|
|
61
64
|
</FlowResultContext.Provider>
|
|
62
65
|
);
|
|
@@ -8,6 +8,7 @@ import {FunctionComponent} from 'preact';
|
|
|
8
8
|
|
|
9
9
|
import {Util} from '../../report/renderer/util';
|
|
10
10
|
import {FlowStepIcon, FlowStepThumbnail} from './common';
|
|
11
|
+
import {useUIStrings} from './i18n/i18n';
|
|
11
12
|
import {getModeDescription, useFlowResult} from './util';
|
|
12
13
|
|
|
13
14
|
const SIDE_THUMBNAIL_HEIGHT = 80;
|
|
@@ -38,6 +39,9 @@ export const Header: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
|
|
|
38
39
|
const prevStep = flowResult.steps[index - 1];
|
|
39
40
|
const nextStep = flowResult.steps[index + 1];
|
|
40
41
|
|
|
42
|
+
const strings = useUIStrings();
|
|
43
|
+
const modeDescription = getModeDescription(step.lhr.gatherMode, strings);
|
|
44
|
+
|
|
41
45
|
return (
|
|
42
46
|
<div className="Header">
|
|
43
47
|
{
|
|
@@ -61,7 +65,7 @@ export const Header: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
|
|
|
61
65
|
<div className="Header__current-title">
|
|
62
66
|
{step.name}
|
|
63
67
|
<div className="Header__current-description">
|
|
64
|
-
{
|
|
68
|
+
{modeDescription}
|
|
65
69
|
</div>
|
|
66
70
|
</div>
|
|
67
71
|
{
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {createContext, FunctionComponent} from 'preact';
|
|
8
|
+
import {useContext, useMemo} from 'preact/hooks';
|
|
9
|
+
|
|
10
|
+
import {I18n} from '../../../report/renderer/i18n';
|
|
11
|
+
import {UIStrings} from './ui-strings';
|
|
12
|
+
import {useLocale} from '../util';
|
|
13
|
+
import strings from './localized-strings';
|
|
14
|
+
|
|
15
|
+
const I18nContext = createContext<I18n<typeof UIStrings>|undefined>(undefined);
|
|
16
|
+
|
|
17
|
+
export function useI18n() {
|
|
18
|
+
const i18n = useContext(I18nContext);
|
|
19
|
+
if (!i18n) throw Error('i18n was not initialized');
|
|
20
|
+
return i18n;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useUIStrings() {
|
|
24
|
+
const i18n = useI18n();
|
|
25
|
+
return i18n.strings;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const I18nProvider: FunctionComponent = ({children}) => {
|
|
29
|
+
const locale = useLocale();
|
|
30
|
+
const i18n = useMemo(() => new I18n(locale, {
|
|
31
|
+
// Set missing renderer strings to default (english) values.
|
|
32
|
+
...UIStrings,
|
|
33
|
+
// `strings` is generated in build/build-report.js
|
|
34
|
+
...strings[locale],
|
|
35
|
+
}), [locale]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<I18nContext.Provider value={i18n}>
|
|
39
|
+
{children}
|
|
40
|
+
</I18nContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @type {Record<LH.Locale, import('./ui-strings.js').UIStringsType>} */
|
|
8
|
+
// @ts-expect-error This will be replaced with the localized strings at build time.
|
|
9
|
+
const strings = {};
|
|
10
|
+
|
|
11
|
+
export default strings;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @typedef {typeof UIStrings} UIStringsType */
|
|
8
|
+
|
|
9
|
+
export const UIStrings = {
|
|
10
|
+
/** Description of a report that evaluates a web page as it loads, but before the user interacts with it. */
|
|
11
|
+
navigationDescription: 'Page load',
|
|
12
|
+
/** Description of a report that evaluates a web page over a period of time where a user could have interacted with the page. */
|
|
13
|
+
timespanDescription: 'User interactions',
|
|
14
|
+
/** Description of a report that evaluates the state of a web page at a single point in time. */
|
|
15
|
+
snapshotDescription: 'Captured state of page',
|
|
16
|
+
/** Label for a report that evaluates a page navigation. */
|
|
17
|
+
navigationReport: 'Navigation report',
|
|
18
|
+
/** Label for a report that evaluates a period of time where a user could have interacted with the page. */
|
|
19
|
+
timespanReport: 'Timespan report',
|
|
20
|
+
/** Label for a report that evaluates the state of a web page at a single point in time. */
|
|
21
|
+
snapshotReport: 'Snapshot report',
|
|
22
|
+
/** Title of a home page that summarizes and links to the other pages. */
|
|
23
|
+
summary: 'Summary',
|
|
24
|
+
/** Title of a report section lists and links to multiple sub-reports. */
|
|
25
|
+
allReports: 'All Reports',
|
|
26
|
+
/** Default title of a Lighthouse report over a user flow. "User Flow" refers to a series of user interactions on a page that a site developer wants to test. "Lighthouse" is a product name https://developers.google.com/web/tools/lighthouse. */
|
|
27
|
+
title: 'Lighthouse User Flow Report',
|
|
28
|
+
/** Label for a report evaluating a web page. Label indicates that the report refers to the desktop version of the site. */
|
|
29
|
+
desktop: 'Desktop',
|
|
30
|
+
/** Label for a report evaluating a web page. Label indicates that the report refers to the mobile version of the site. */
|
|
31
|
+
mobile: 'Mobile',
|
|
32
|
+
/** Rating indicating that a report category is good/passing. */
|
|
33
|
+
ratingPass: 'Good',
|
|
34
|
+
/** Rating indicating that a report category is average or needs improvement. */
|
|
35
|
+
ratingAverage: 'Average',
|
|
36
|
+
/** Rating indicating that a report category is poor/failing. */
|
|
37
|
+
ratingFail: 'Poor',
|
|
38
|
+
/** Rating indicating that a report category rating could not be calculated because of an error. */
|
|
39
|
+
ratingError: 'Error',
|
|
40
|
+
};
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {FunctionComponent} from 'preact';
|
|
8
|
-
import {useMemo} from 'preact/hooks';
|
|
9
8
|
|
|
10
9
|
import {Separator} from '../common';
|
|
10
|
+
import {useI18n, useUIStrings} from '../i18n/i18n';
|
|
11
11
|
import {CpuIcon, EnvIcon, SummaryIcon} from '../icons';
|
|
12
|
-
import {classNames, useCurrentLhr, useFlowResult
|
|
12
|
+
import {classNames, useCurrentLhr, useFlowResult} from '../util';
|
|
13
13
|
import {SidebarFlow} from './flow';
|
|
14
14
|
|
|
15
15
|
export const SidebarSummary: FunctionComponent = () => {
|
|
16
16
|
const currentLhr = useCurrentLhr();
|
|
17
|
+
const strings = useUIStrings();
|
|
18
|
+
|
|
17
19
|
const url = new URL(location.href);
|
|
18
20
|
url.hash = '#';
|
|
19
21
|
return (
|
|
@@ -25,12 +27,14 @@ export const SidebarSummary: FunctionComponent = () => {
|
|
|
25
27
|
<div className="SidebarSummary__icon">
|
|
26
28
|
<SummaryIcon/>
|
|
27
29
|
</div>
|
|
28
|
-
<div className="SidebarSummary__label">
|
|
30
|
+
<div className="SidebarSummary__label">{strings.summary}</div>
|
|
29
31
|
</a>
|
|
30
32
|
);
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> = ({settings}) => {
|
|
36
|
+
const strings = useUIStrings();
|
|
37
|
+
|
|
34
38
|
return (
|
|
35
39
|
<div className="SidebarRuntimeSettings">
|
|
36
40
|
<div className="SidebarRuntimeSettings__item">
|
|
@@ -38,8 +42,7 @@ const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> =
|
|
|
38
42
|
<EnvIcon/>
|
|
39
43
|
</div>
|
|
40
44
|
{
|
|
41
|
-
|
|
42
|
-
`${settings.screenEmulation.height}x${settings.screenEmulation.width}px`
|
|
45
|
+
settings.formFactor === 'desktop' ? strings.desktop : strings.mobile
|
|
43
46
|
}
|
|
44
47
|
</div>
|
|
45
48
|
<div className="SidebarRuntimeSettings__item">
|
|
@@ -55,19 +58,11 @@ const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> =
|
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
export const SidebarHeader: FunctionComponent<{title: string, date: string}> = ({title, date}) => {
|
|
58
|
-
const
|
|
59
|
-
const formatter = useMemo(() => {
|
|
60
|
-
const options: Intl.DateTimeFormatOptions = {
|
|
61
|
-
month: 'short', day: 'numeric', year: 'numeric',
|
|
62
|
-
hour: 'numeric', minute: 'numeric', timeZoneName: 'short',
|
|
63
|
-
};
|
|
64
|
-
return new Intl.DateTimeFormat(locale, options);
|
|
65
|
-
}, [locale]);
|
|
66
|
-
const dateString = useMemo(() => formatter.format(new Date(date)), [date, formatter]);
|
|
61
|
+
const i18n = useI18n();
|
|
67
62
|
return (
|
|
68
63
|
<div className="SidebarHeader">
|
|
69
64
|
<div className="SidebarHeader__title">{title}</div>
|
|
70
|
-
<div className="SidebarHeader__date">{
|
|
65
|
+
<div className="SidebarHeader__date">{i18n.formatDateTime(date)}</div>
|
|
71
66
|
</div>
|
|
72
67
|
);
|
|
73
68
|
};
|
|
@@ -9,24 +9,32 @@ import {FunctionComponent} from 'preact';
|
|
|
9
9
|
import {Util} from '../../../report/renderer/util';
|
|
10
10
|
import {Separator} from '../common';
|
|
11
11
|
import {CategoryScore} from '../wrappers/category-score';
|
|
12
|
+
import {useUIStrings} from '../i18n/i18n';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
'navigation': 'Navigation report',
|
|
15
|
-
'timespan': 'Timespan report',
|
|
16
|
-
'snapshot': 'Snapshot report',
|
|
17
|
-
};
|
|
14
|
+
import type {UIStringsType} from '../i18n/ui-strings';
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
16
|
+
function getGatherModeLabel(gatherMode: LH.Result.GatherMode, strings: UIStringsType) {
|
|
17
|
+
switch (gatherMode) {
|
|
18
|
+
case 'navigation': return strings.navigationReport;
|
|
19
|
+
case 'timespan': return strings.timespanReport;
|
|
20
|
+
case 'snapshot': return strings.snapshotReport;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getCategoryRating(rating: string, strings: UIStringsType) {
|
|
25
|
+
switch (rating) {
|
|
26
|
+
case 'pass': return strings.ratingPass;
|
|
27
|
+
case 'average': return strings.ratingAverage;
|
|
28
|
+
case 'fail': return strings.ratingFail;
|
|
29
|
+
case 'error': return strings.ratingError;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
|
|
26
33
|
export const SummaryTooltip: FunctionComponent<{
|
|
27
34
|
category: LH.ReportResult.Category,
|
|
28
35
|
gatherMode: LH.Result.GatherMode
|
|
29
36
|
}> = ({category, gatherMode}) => {
|
|
37
|
+
const strings = useUIStrings();
|
|
30
38
|
const {numPassed, numAudits, totalWeight} = Util.calculateCategoryFraction(category);
|
|
31
39
|
|
|
32
40
|
const displayAsFraction = Util.shouldDisplayAsFraction(gatherMode);
|
|
@@ -36,7 +44,7 @@ export const SummaryTooltip: FunctionComponent<{
|
|
|
36
44
|
|
|
37
45
|
return (
|
|
38
46
|
<div className="SummaryTooltip">
|
|
39
|
-
<div className="SummaryTooltip__title">{
|
|
47
|
+
<div className="SummaryTooltip__title">{getGatherModeLabel(gatherMode, strings)}</div>
|
|
40
48
|
<Separator/>
|
|
41
49
|
<div className="SummaryTooltip__category">
|
|
42
50
|
<div className="SummaryTooltip__category-title">
|
|
@@ -48,7 +56,7 @@ export const SummaryTooltip: FunctionComponent<{
|
|
|
48
56
|
className={`SummaryTooltip__rating SummaryTooltip__rating--${rating}`}
|
|
49
57
|
data-testid="SummaryTooltip__rating"
|
|
50
58
|
>
|
|
51
|
-
<span>{
|
|
59
|
+
<span>{getCategoryRating(rating, strings)}</span>
|
|
52
60
|
{
|
|
53
61
|
!displayAsFraction && category.score && <>
|
|
54
62
|
<span> · </span>
|
|
@@ -11,19 +11,28 @@ import {FlowSegment, FlowStepThumbnail, Separator} from '../common';
|
|
|
11
11
|
import {getModeDescription, useFlowResult} from '../util';
|
|
12
12
|
import {Util} from '../../../report/renderer/util';
|
|
13
13
|
import {SummaryCategory} from './category';
|
|
14
|
+
import {useUIStrings} from '../i18n/i18n';
|
|
14
15
|
|
|
15
16
|
const DISPLAYED_CATEGORIES = ['performance', 'accessibility', 'best-practices', 'seo'];
|
|
16
17
|
const THUMBNAIL_WIDTH = 50;
|
|
17
18
|
|
|
18
|
-
const SummaryNavigationHeader: FunctionComponent<{
|
|
19
|
+
const SummaryNavigationHeader: FunctionComponent<{lhr: LH.Result}> = ({lhr}) => {
|
|
19
20
|
return (
|
|
20
21
|
<div className="SummaryNavigationHeader" data-testid="SummaryNavigationHeader">
|
|
21
22
|
<FlowSegment/>
|
|
22
|
-
<div className="SummaryNavigationHeader__url">{
|
|
23
|
-
<div className="SummaryNavigationHeader__category">
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<div className="SummaryNavigationHeader__category">
|
|
23
|
+
<div className="SummaryNavigationHeader__url">{lhr.finalUrl}</div>
|
|
24
|
+
<div className="SummaryNavigationHeader__category">
|
|
25
|
+
{lhr.categories['performance'].title}
|
|
26
|
+
</div>
|
|
27
|
+
<div className="SummaryNavigationHeader__category">
|
|
28
|
+
{lhr.categories['accessibility'].title}
|
|
29
|
+
</div>
|
|
30
|
+
<div className="SummaryNavigationHeader__category">
|
|
31
|
+
{lhr.categories['best-practices'].title}
|
|
32
|
+
</div>
|
|
33
|
+
<div className="SummaryNavigationHeader__category">
|
|
34
|
+
{lhr.categories['seo'].title}
|
|
35
|
+
</div>
|
|
27
36
|
</div>
|
|
28
37
|
);
|
|
29
38
|
};
|
|
@@ -37,12 +46,14 @@ export const SummaryFlowStep: FunctionComponent<{
|
|
|
37
46
|
hashIndex: number,
|
|
38
47
|
}> = ({lhr, label, hashIndex}) => {
|
|
39
48
|
const reportResult = useMemo(() => Util.prepareReportResult(lhr), [lhr]);
|
|
49
|
+
const strings = useUIStrings();
|
|
50
|
+
const modeDescription = getModeDescription(lhr.gatherMode, strings);
|
|
40
51
|
|
|
41
52
|
return (
|
|
42
53
|
<div className="SummaryFlowStep">
|
|
43
54
|
{
|
|
44
55
|
lhr.gatherMode === 'navigation' || hashIndex === 0 ?
|
|
45
|
-
<SummaryNavigationHeader
|
|
56
|
+
<SummaryNavigationHeader lhr={lhr}/> :
|
|
46
57
|
<div className="SummaryFlowStep__separator">
|
|
47
58
|
<FlowSegment/>
|
|
48
59
|
<Separator/>
|
|
@@ -54,7 +65,7 @@ export const SummaryFlowStep: FunctionComponent<{
|
|
|
54
65
|
}
|
|
55
66
|
<FlowSegment mode={lhr.gatherMode}/>
|
|
56
67
|
<div className="SummaryFlowStep__label">
|
|
57
|
-
<div className="SummaryFlowStep__mode">{
|
|
68
|
+
<div className="SummaryFlowStep__mode">{modeDescription}</div>
|
|
58
69
|
<a className="SummaryFlowStep__link" href={`#index=${hashIndex}`}>{label}</a>
|
|
59
70
|
</div>
|
|
60
71
|
{
|
|
@@ -95,6 +106,7 @@ const SummaryFlow: FunctionComponent = () => {
|
|
|
95
106
|
|
|
96
107
|
export const SummaryHeader: FunctionComponent = () => {
|
|
97
108
|
const flowResult = useFlowResult();
|
|
109
|
+
const strings = useUIStrings();
|
|
98
110
|
|
|
99
111
|
let numNavigation = 0;
|
|
100
112
|
let numTimespan = 0;
|
|
@@ -121,7 +133,7 @@ export const SummaryHeader: FunctionComponent = () => {
|
|
|
121
133
|
|
|
122
134
|
return (
|
|
123
135
|
<div className="SummaryHeader">
|
|
124
|
-
<div className="SummaryHeader__title">
|
|
136
|
+
<div className="SummaryHeader__title">{strings.summary}</div>
|
|
125
137
|
<div className="SummaryHeader__subtitle">{subtitle}</div>
|
|
126
138
|
</div>
|
|
127
139
|
);
|
|
@@ -137,11 +149,13 @@ const SummarySectionHeader: FunctionComponent = ({children}) => {
|
|
|
137
149
|
};
|
|
138
150
|
|
|
139
151
|
export const Summary: FunctionComponent = () => {
|
|
152
|
+
const strings = useUIStrings();
|
|
153
|
+
|
|
140
154
|
return (
|
|
141
155
|
<div className="Summary" data-testid="Summary">
|
|
142
156
|
<SummaryHeader/>
|
|
143
157
|
<Separator/>
|
|
144
|
-
<SummarySectionHeader>
|
|
158
|
+
<SummarySectionHeader>{strings.allReports}</SummarySectionHeader>
|
|
145
159
|
<SummaryFlow/>
|
|
146
160
|
</div>
|
|
147
161
|
);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {FunctionComponent, JSX} from 'preact';
|
|
8
8
|
|
|
9
|
+
import {useUIStrings} from './i18n/i18n';
|
|
9
10
|
import {HamburgerIcon} from './icons';
|
|
10
11
|
|
|
11
12
|
/* eslint-disable max-len */
|
|
@@ -46,6 +47,8 @@ const Logo: FunctionComponent = () => {
|
|
|
46
47
|
|
|
47
48
|
export const Topbar: FunctionComponent<{onMenuClick: JSX.MouseEventHandler<HTMLDivElement>}> =
|
|
48
49
|
({onMenuClick}) => {
|
|
50
|
+
const strings = useUIStrings();
|
|
51
|
+
|
|
49
52
|
return (
|
|
50
53
|
<div className="Topbar">
|
|
51
54
|
<div className="Topbar__menu" onClick={onMenuClick} role="button">
|
|
@@ -54,7 +57,7 @@ export const Topbar: FunctionComponent<{onMenuClick: JSX.MouseEventHandler<HTMLD
|
|
|
54
57
|
<div className="Topbar__logo">
|
|
55
58
|
<Logo/>
|
|
56
59
|
</div>
|
|
57
|
-
<div className="Topbar__title">
|
|
60
|
+
<div className="Topbar__title">{strings.title}</div>
|
|
58
61
|
</div>
|
|
59
62
|
);
|
|
60
63
|
};
|
package/flow-report/src/util.ts
CHANGED
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
import {createContext} from 'preact';
|
|
8
8
|
import {useContext, useEffect, useMemo, useState} from 'preact/hooks';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
'navigation': 'Page load',
|
|
12
|
-
'timespan': 'User interactions',
|
|
13
|
-
'snapshot': 'Captured state of page',
|
|
14
|
-
};
|
|
10
|
+
import type {UIStringsType} from './i18n/ui-strings';
|
|
15
11
|
|
|
16
12
|
export const FlowResultContext = createContext<LH.FlowResult|undefined>(undefined);
|
|
17
13
|
|
|
@@ -54,8 +50,12 @@ export function getScreenshot(reportResult: LH.ReportResult) {
|
|
|
54
50
|
return fullPageScreenshot || null;
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
export function getModeDescription(mode: LH.Result.GatherMode) {
|
|
58
|
-
|
|
53
|
+
export function getModeDescription(mode: LH.Result.GatherMode, strings: UIStringsType) {
|
|
54
|
+
switch (mode) {
|
|
55
|
+
case 'navigation': return strings.navigationDescription;
|
|
56
|
+
case 'timespan': return strings.timespanDescription;
|
|
57
|
+
case 'snapshot': return strings.snapshotDescription;
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function useFlowResult(): LH.FlowResult {
|
|
@@ -4,21 +4,10 @@
|
|
|
4
4
|
* 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.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import {dirname} from 'path';
|
|
9
|
-
import {fileURLToPath} from 'url';
|
|
10
|
-
|
|
11
7
|
import {render} from '@testing-library/preact';
|
|
12
8
|
|
|
13
9
|
import {App} from '../src/app';
|
|
14
|
-
|
|
15
|
-
const flowResult = JSON.parse(
|
|
16
|
-
fs.readFileSync(
|
|
17
|
-
// eslint-disable-next-line max-len
|
|
18
|
-
`${dirname(fileURLToPath(import.meta.url))}/../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
|
|
19
|
-
'utf-8'
|
|
20
|
-
)
|
|
21
|
-
);
|
|
10
|
+
import {flowResult} from './sample-flow';
|
|
22
11
|
|
|
23
12
|
it('renders a standalone report with summary', async () => {
|
|
24
13
|
const root = render(<App flowResult={flowResult}/>);
|
|
@@ -4,29 +4,23 @@
|
|
|
4
4
|
* 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.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import {dirname} from 'path';
|
|
9
|
-
import {fileURLToPath} from 'url';
|
|
10
|
-
|
|
11
7
|
import {FunctionComponent} from 'preact';
|
|
12
8
|
import {render} from '@testing-library/preact';
|
|
13
9
|
|
|
14
10
|
import {Header} from '../src/header';
|
|
15
11
|
import {FlowResultContext} from '../src/util';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fs.readFileSync(
|
|
19
|
-
// eslint-disable-next-line max-len
|
|
20
|
-
`${dirname(fileURLToPath(import.meta.url))}/../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
|
|
21
|
-
'utf-8'
|
|
22
|
-
)
|
|
23
|
-
);
|
|
12
|
+
import {flowResult} from './sample-flow';
|
|
13
|
+
import {I18nProvider} from '../src/i18n/i18n';
|
|
24
14
|
|
|
25
15
|
let wrapper: FunctionComponent;
|
|
26
16
|
|
|
27
17
|
beforeEach(() => {
|
|
28
18
|
wrapper = ({children}) => (
|
|
29
|
-
<FlowResultContext.Provider value={flowResult}>
|
|
19
|
+
<FlowResultContext.Provider value={flowResult}>
|
|
20
|
+
<I18nProvider>
|
|
21
|
+
{children}
|
|
22
|
+
</I18nProvider>
|
|
23
|
+
</FlowResultContext.Provider>
|
|
30
24
|
);
|
|
31
25
|
});
|
|
32
26
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import {dirname} from 'path';
|
|
9
|
+
import {fileURLToPath} from 'url';
|
|
10
|
+
|
|
11
|
+
export const flowResult: LH.FlowResult = JSON.parse(
|
|
12
|
+
fs.readFileSync(
|
|
13
|
+
// eslint-disable-next-line max-len
|
|
14
|
+
`${dirname(fileURLToPath(import.meta.url))}/../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`,
|
|
15
|
+
'utf-8'
|
|
16
|
+
)
|
|
17
|
+
);
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
4
6
|
|
|
5
7
|
import {render} from '@testing-library/preact';
|
|
6
8
|
import {FunctionComponent} from 'preact';
|
|
7
9
|
|
|
8
10
|
import {SidebarFlow} from '../../src/sidebar/flow';
|
|
9
11
|
import {FlowResultContext} from '../../src/util';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const flowResult = JSON.parse(
|
|
13
|
-
fs.readFileSync(
|
|
14
|
-
// eslint-disable-next-line max-len
|
|
15
|
-
`${dirname(fileURLToPath(import.meta.url))}/../../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
|
|
16
|
-
'utf-8'
|
|
17
|
-
)
|
|
18
|
-
);
|
|
12
|
+
import {flowResult} from '../sample-flow';
|
|
19
13
|
|
|
20
14
|
let wrapper: FunctionComponent;
|
|
21
15
|
|
|
@@ -4,30 +4,24 @@
|
|
|
4
4
|
* 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.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import {dirname} from 'path';
|
|
9
|
-
import {fileURLToPath} from 'url';
|
|
10
|
-
|
|
11
7
|
import {render} from '@testing-library/preact';
|
|
12
8
|
import {FunctionComponent} from 'preact';
|
|
13
9
|
|
|
10
|
+
import {I18nProvider} from '../../src/i18n/i18n';
|
|
14
11
|
import {SidebarHeader, SidebarSummary} from '../../src/sidebar/sidebar';
|
|
15
12
|
import {FlowResultContext} from '../../src/util';
|
|
13
|
+
import {flowResult} from '../sample-flow';
|
|
16
14
|
|
|
17
15
|
|
|
18
|
-
const flowResult = JSON.parse(
|
|
19
|
-
fs.readFileSync(
|
|
20
|
-
// eslint-disable-next-line max-len
|
|
21
|
-
`${dirname(fileURLToPath(import.meta.url))}/../../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
|
|
22
|
-
'utf-8'
|
|
23
|
-
)
|
|
24
|
-
);
|
|
25
|
-
|
|
26
16
|
let wrapper: FunctionComponent;
|
|
27
17
|
|
|
28
18
|
beforeEach(() => {
|
|
29
19
|
wrapper = ({children}) => (
|
|
30
|
-
<FlowResultContext.Provider value={flowResult}>
|
|
20
|
+
<FlowResultContext.Provider value={flowResult}>
|
|
21
|
+
<I18nProvider>
|
|
22
|
+
{children}
|
|
23
|
+
</I18nProvider>
|
|
24
|
+
</FlowResultContext.Provider>
|
|
31
25
|
);
|
|
32
26
|
});
|
|
33
27
|
|