lighthouse 8.6.0 → 9.0.0
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/dist/report/bundle.esm.js +5994 -0
- package/dist/report/flow.js +30 -13
- package/dist/report/standalone.js +41 -35
- package/flow-report/.eslintrc.cjs +2 -0
- package/flow-report/assets/standalone-flow-template.html +3 -2
- package/flow-report/assets/styles.css +108 -31
- package/flow-report/src/app.tsx +18 -18
- package/flow-report/src/common.tsx +28 -15
- package/flow-report/src/header.tsx +12 -13
- package/flow-report/src/help-dialog.tsx +3 -4
- package/flow-report/src/i18n/i18n.tsx +57 -16
- package/flow-report/src/i18n/ui-strings.js +50 -0
- package/flow-report/src/icons.tsx +36 -8
- package/flow-report/src/sidebar/flow.tsx +3 -3
- package/flow-report/src/sidebar/sidebar.tsx +35 -14
- package/flow-report/src/summary/category.tsx +97 -24
- package/flow-report/src/summary/summary.tsx +21 -14
- package/flow-report/src/topbar.tsx +9 -5
- package/flow-report/src/util.ts +33 -26
- package/flow-report/src/wrappers/category-score.tsx +0 -3
- package/flow-report/src/wrappers/markdown.tsx +27 -0
- package/flow-report/src/wrappers/report-renderer.tsx +10 -3
- package/flow-report/src/wrappers/report.tsx +27 -6
- package/flow-report/standalone-flow.tsx +4 -3
- package/flow-report/test/common-test.tsx +32 -17
- package/flow-report/test/flow-report-pptr-test.ts +46 -0
- package/flow-report/test/header-test.tsx +6 -6
- package/flow-report/test/setup/env-setup.ts +1 -1
- package/flow-report/test/sidebar/sidebar-test.tsx +43 -1
- package/flow-report/test/summary/category-test.tsx +120 -24
- package/flow-report/test/summary/summary-test.tsx +1 -1
- package/flow-report/test/topbar-test.tsx +1 -0
- package/flow-report/test/util-test.tsx +32 -11
- package/flow-report/test/wrappers/category-score-test.tsx +87 -0
- package/flow-report/test/wrappers/markdown-test.tsx +29 -0
- package/flow-report/tsconfig.json +1 -0
- package/jest.config.js +4 -2
- package/lighthouse-cli/.eslintrc.cjs +2 -0
- package/lighthouse-cli/cli-flags.js +1 -1
- package/lighthouse-cli/run.js +1 -1
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -0
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +4 -2
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-core/audits/accessibility/axe-audit.js +7 -1
- package/lighthouse-core/audits/audit.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -0
- package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +4 -2
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +11 -10
- package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +5 -3
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +2 -1
- package/lighthouse-core/audits/deprecations.js +33 -11
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +27 -11
- package/lighthouse-core/audits/errors-in-console.js +0 -2
- package/lighthouse-core/audits/image-aspect-ratio.js +5 -5
- package/lighthouse-core/audits/image-size-responsive.js +6 -6
- package/lighthouse-core/audits/installable-manifest.js +5 -3
- package/lighthouse-core/audits/preload-lcp-image.js +7 -5
- package/lighthouse-core/audits/script-treemap-data.js +1 -1
- package/lighthouse-core/audits/unsized-images.js +2 -3
- package/lighthouse-core/computed/image-records.js +4 -3
- package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +3 -4
- package/lighthouse-core/computed/metrics/tbt-utils.js +57 -0
- package/lighthouse-core/computed/metrics/total-blocking-time.js +3 -53
- package/lighthouse-core/computed/resource-summary.js +1 -1
- package/lighthouse-core/config/config-helpers.js +21 -10
- package/lighthouse-core/config/constants.js +3 -4
- package/lighthouse-core/config/default-config.js +61 -71
- package/lighthouse-core/fraggle-rock/config/config.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +4 -5
- package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +6 -1
- package/lighthouse-core/fraggle-rock/gather/session.js +3 -4
- package/lighthouse-core/gather/connections/cri.js +1 -1
- package/lighthouse-core/gather/driver/storage.js +0 -1
- package/lighthouse-core/gather/driver.js +3 -7
- package/lighthouse-core/gather/fetcher.js +4 -7
- package/lighthouse-core/gather/gather-runner.js +29 -6
- package/lighthouse-core/gather/gatherers/accessibility.js +27 -0
- package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -0
- package/lighthouse-core/gather/gatherers/image-elements.js +0 -3
- package/lighthouse-core/gather/gatherers/inspector-issues.js +5 -0
- package/lighthouse-core/lib/asset-saver.js +7 -4
- package/lighthouse-core/lib/emulation.js +45 -1
- package/lighthouse-core/lib/i18n/i18n.js +19 -8
- package/lighthouse-core/lib/lh-env.js +2 -0
- package/lighthouse-core/lib/proto-preprocessor.js +14 -2
- package/lighthouse-core/lib/tappable-rects.js +8 -15
- package/lighthouse-core/lib/url-shim.js +1 -1
- package/lighthouse-core/runner.js +1 -1
- package/lighthouse-core/util-commonjs.js +65 -46
- package/package.json +27 -17
- package/readme.md +3 -3
- package/report/.eslintrc.cjs +2 -0
- package/report/README.md +1 -1
- package/report/assets/standalone-template.html +2 -3
- package/report/assets/styles.css +360 -254
- package/report/assets/templates.html +21 -76
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +6 -15
- package/report/generator/README.md +1 -1
- package/report/renderer/api.js +32 -0
- package/report/renderer/category-renderer.js +59 -19
- package/report/renderer/components.js +59 -110
- package/report/renderer/crc-details-renderer.js +15 -12
- package/report/renderer/dom.js +16 -1
- package/report/renderer/drop-down-menu.js +2 -2
- package/report/renderer/element-screenshot-renderer.js +8 -8
- package/report/renderer/features-util.js +1 -1
- package/report/renderer/open-tab.js +9 -3
- package/report/renderer/performance-category-renderer.js +55 -34
- package/report/renderer/pwa-category-renderer.js +0 -10
- package/report/renderer/report-renderer.js +91 -44
- package/report/renderer/report-ui-features.js +36 -33
- package/report/renderer/swap-locale-feature.js +3 -3
- package/report/renderer/topbar-features.js +53 -48
- package/report/renderer/util.js +66 -46
- package/report/test/clients/bundle-test.js +70 -0
- package/report/test/renderer/category-renderer-test.js +48 -3
- package/report/test/renderer/i18n-test.js +0 -7
- package/report/test/renderer/performance-category-renderer-test.js +51 -14
- package/report/test/renderer/pwa-category-renderer-test.js +6 -6
- package/report/test/renderer/report-renderer-axe-test.js +10 -12
- package/report/test/renderer/report-renderer-test.js +23 -22
- package/report/test/renderer/report-ui-features-test.js +20 -10
- package/report/test/renderer/text-encoding-test.js +1 -1
- package/report/test/renderer/util-test.js +35 -31
- package/report/test-assets/faux-psi-template.html +3 -11
- package/report/test-assets/faux-psi.js +26 -22
- package/report/types/html-renderer.d.ts +2 -0
- package/report/types/report-renderer.d.ts +23 -0
- package/shared/localization/format.js +64 -30
- package/shared/localization/locales/ar-XB.json +72 -75
- package/shared/localization/locales/ar.json +72 -75
- package/shared/localization/locales/bg.json +72 -75
- package/shared/localization/locales/ca.json +72 -75
- package/shared/localization/locales/cs.json +89 -92
- package/shared/localization/locales/da.json +72 -75
- package/shared/localization/locales/de.json +89 -92
- package/shared/localization/locales/el.json +72 -75
- package/shared/localization/locales/en-GB.json +72 -75
- package/shared/localization/locales/en-US.json +75 -75
- package/shared/localization/locales/en-XA.json +72 -75
- package/shared/localization/locales/en-XL.json +75 -75
- package/shared/localization/locales/es-419.json +90 -93
- package/shared/localization/locales/es.json +90 -93
- package/shared/localization/locales/fi.json +72 -75
- package/shared/localization/locales/fil.json +72 -75
- package/shared/localization/locales/fr.json +89 -92
- package/shared/localization/locales/he.json +73 -76
- package/shared/localization/locales/hi.json +72 -75
- package/shared/localization/locales/hr.json +72 -75
- package/shared/localization/locales/hu.json +89 -92
- package/shared/localization/locales/id.json +89 -92
- package/shared/localization/locales/it.json +89 -92
- package/shared/localization/locales/ja.json +89 -92
- package/shared/localization/locales/ko.json +89 -92
- package/shared/localization/locales/lt.json +89 -92
- package/shared/localization/locales/lv.json +95 -98
- package/shared/localization/locales/nl.json +89 -92
- package/shared/localization/locales/no.json +72 -75
- package/shared/localization/locales/pl.json +72 -75
- package/shared/localization/locales/pt-PT.json +72 -75
- package/shared/localization/locales/pt.json +89 -92
- package/shared/localization/locales/ro.json +90 -93
- package/shared/localization/locales/ru.json +89 -92
- package/shared/localization/locales/sk.json +89 -92
- package/shared/localization/locales/sl.json +89 -92
- package/shared/localization/locales/sr-Latn.json +89 -92
- package/shared/localization/locales/sr.json +89 -92
- package/shared/localization/locales/sv.json +72 -75
- package/shared/localization/locales/ta.json +89 -92
- package/shared/localization/locales/te.json +89 -92
- package/shared/localization/locales/th.json +89 -92
- package/shared/localization/locales/tr.json +89 -92
- package/shared/localization/locales/uk.json +92 -95
- package/shared/localization/locales/vi.json +89 -92
- package/shared/localization/locales/zh-HK.json +89 -92
- package/shared/localization/locales/zh-TW.json +89 -92
- package/shared/localization/locales/zh.json +89 -92
- package/shared/localization/locales.js +6 -0
- package/shared/test/localization/format-test.js +45 -9
- package/shared/test/localization/swap-locale-test.js +0 -12
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +19 -11
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
- package/third-party/download-content-shell/download-content-shell.js +2 -2
- package/third-party/download-content-shell/utils.js +0 -24
- package/tsconfig-all.json +2 -2
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +7 -7
- package/types/enquirer.d.ts +3 -1
- package/types/lhr/audit-details.d.ts +6 -5
- package/types/lhr/flow.d.ts +3 -2
- package/types/lhr/lhr.d.ts +1 -1
- package/types/node.d.ts +5 -5
- package/types/rollup-plugin-postprocess.d.ts +10 -0
- package/changelog.md +0 -5490
- package/lighthouse-core/audits/dobetterweb/appcache-manifest.js +0 -67
- package/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js +0 -96
- package/lighthouse-core/audits/redirects-http.js +0 -59
- package/lighthouse-core/gather/gatherers/dobetterweb/appcache.js +0 -34
- package/lighthouse-core/gather/gatherers/http-redirect.js +0 -46
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +0 -6699
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +0 -6672
- package/lighthouse-core/scripts/package.json +0 -4
- package/report/clients/psi.js +0 -158
- package/report/test/clients/psi-test.js +0 -143
- package/shared/localization/locales/en-US.ctc.json +0 -6877
- package/shared/localization/locales/en-XL.ctc.json +0 -6852
|
@@ -11,6 +11,7 @@ import {SummaryTooltip} from '../../src/summary/category';
|
|
|
11
11
|
import {flowResult} from '../sample-flow';
|
|
12
12
|
import {I18nProvider} from '../../src/i18n/i18n';
|
|
13
13
|
import {FlowResultContext} from '../../src/util';
|
|
14
|
+
import {ReportRendererProvider} from '../../src/wrappers/report-renderer';
|
|
14
15
|
|
|
15
16
|
let wrapper: FunctionComponent;
|
|
16
17
|
|
|
@@ -18,9 +19,11 @@ beforeEach(() => {
|
|
|
18
19
|
// Include sample flowResult for locale in I18nProvider.
|
|
19
20
|
wrapper = ({children}) => (
|
|
20
21
|
<FlowResultContext.Provider value={flowResult}>
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
<ReportRendererProvider>
|
|
23
|
+
<I18nProvider>
|
|
24
|
+
{children}
|
|
25
|
+
</I18nProvider>
|
|
26
|
+
</ReportRendererProvider>
|
|
24
27
|
</FlowResultContext.Provider>
|
|
25
28
|
);
|
|
26
29
|
});
|
|
@@ -31,20 +34,24 @@ describe('SummaryTooltip', () => {
|
|
|
31
34
|
id: 'performance',
|
|
32
35
|
score: 1,
|
|
33
36
|
auditRefs: [
|
|
34
|
-
|
|
35
|
-
{result: {score: 1, scoreDisplayMode: 'binary'}, weight: 1, group: 'diagnostics'},
|
|
36
|
-
{result: {score:
|
|
37
|
+
/* eslint-disable max-len */
|
|
38
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
|
|
39
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
|
|
40
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
|
|
41
|
+
/* eslint-enable max-len */
|
|
37
42
|
],
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
const root = render(
|
|
41
|
-
<SummaryTooltip category={category} gatherMode="snapshot"/>,
|
|
46
|
+
<SummaryTooltip category={category} gatherMode="snapshot" url="https://example.com"/>,
|
|
42
47
|
{wrapper}
|
|
43
48
|
);
|
|
44
49
|
|
|
45
50
|
expect(root.getByText('Average')).toBeTruthy();
|
|
46
51
|
expect(() => root.getByText(/^[0-9]+$/)).toThrow();
|
|
47
|
-
expect(root.getByText('2 audits passed
|
|
52
|
+
expect(root.getByText('2 audits passed')).toBeTruthy();
|
|
53
|
+
expect(root.getByText('3 passable audits')).toBeTruthy();
|
|
54
|
+
expect(root.getByText('https://example.com')).toBeTruthy();
|
|
48
55
|
});
|
|
49
56
|
|
|
50
57
|
it('renders tooltip without rating', async () => {
|
|
@@ -52,20 +59,24 @@ describe('SummaryTooltip', () => {
|
|
|
52
59
|
id: 'performance',
|
|
53
60
|
score: 1,
|
|
54
61
|
auditRefs: [
|
|
55
|
-
|
|
56
|
-
{result: {score: 1, scoreDisplayMode: 'binary'}, weight: 0, group: 'diagnostics'},
|
|
57
|
-
{result: {score:
|
|
62
|
+
/* eslint-disable max-len */
|
|
63
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 0, group: 'diagnostics'},
|
|
64
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 0, group: 'diagnostics'},
|
|
65
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 0, group: 'diagnostics'},
|
|
66
|
+
/* eslint-enable max-len */
|
|
58
67
|
],
|
|
59
68
|
};
|
|
60
69
|
|
|
61
70
|
const root = render(
|
|
62
|
-
<SummaryTooltip category={category} gatherMode="snapshot"/>,
|
|
71
|
+
<SummaryTooltip category={category} gatherMode="snapshot" url="https://example.com"/>,
|
|
63
72
|
{wrapper}
|
|
64
73
|
);
|
|
65
74
|
|
|
66
75
|
expect(() => root.getByText(/^(Average|Good|Poor)$/)).toThrow();
|
|
67
76
|
expect(() => root.getByText(/^[0-9]+$/)).toThrow();
|
|
68
|
-
expect(root.getByText('2 audits passed
|
|
77
|
+
expect(root.getByText('2 audits passed')).toBeTruthy();
|
|
78
|
+
expect(root.getByText('3 passable audits')).toBeTruthy();
|
|
79
|
+
expect(root.getByText('https://example.com')).toBeTruthy();
|
|
69
80
|
});
|
|
70
81
|
|
|
71
82
|
it('renders scored category tooltip with score', async () => {
|
|
@@ -73,20 +84,24 @@ describe('SummaryTooltip', () => {
|
|
|
73
84
|
id: 'performance',
|
|
74
85
|
score: 1,
|
|
75
86
|
auditRefs: [
|
|
76
|
-
|
|
77
|
-
{result: {score: 1, scoreDisplayMode: 'binary'}, weight: 1, group: 'diagnostics'},
|
|
78
|
-
{result: {score:
|
|
87
|
+
/* eslint-disable max-len */
|
|
88
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
|
|
89
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
|
|
90
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
|
|
91
|
+
/* eslint-enable max-len */
|
|
79
92
|
],
|
|
80
93
|
};
|
|
81
94
|
|
|
82
95
|
const root = render(
|
|
83
|
-
<SummaryTooltip category={category} gatherMode="navigation"/>,
|
|
96
|
+
<SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
|
|
84
97
|
{wrapper}
|
|
85
98
|
);
|
|
86
99
|
|
|
87
100
|
expect(root.getByText('Good')).toBeTruthy();
|
|
88
101
|
expect(root.getByText('100')).toBeTruthy();
|
|
89
|
-
expect(root.getByText('2 audits passed
|
|
102
|
+
expect(root.getByText('2 audits passed')).toBeTruthy();
|
|
103
|
+
expect(root.getByText('3 passable audits')).toBeTruthy();
|
|
104
|
+
expect(root.getByText('https://example.com')).toBeTruthy();
|
|
90
105
|
});
|
|
91
106
|
|
|
92
107
|
it('renders informative audit count if any', async () => {
|
|
@@ -94,20 +109,101 @@ describe('SummaryTooltip', () => {
|
|
|
94
109
|
id: 'performance',
|
|
95
110
|
score: 1,
|
|
96
111
|
auditRefs: [
|
|
97
|
-
|
|
98
|
-
{result: {score: 1, scoreDisplayMode: 'binary'}, weight: 1, group: 'diagnostics'},
|
|
99
|
-
{result: {score:
|
|
112
|
+
/* eslint-disable max-len */
|
|
113
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
|
|
114
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
|
|
115
|
+
{result: {score: null, scoreDisplayMode: 'informative', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
|
|
116
|
+
/* eslint-enable max-len */
|
|
100
117
|
],
|
|
101
118
|
};
|
|
102
119
|
|
|
103
120
|
const root = render(
|
|
104
|
-
<SummaryTooltip category={category} gatherMode="navigation"/>,
|
|
121
|
+
<SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
|
|
105
122
|
{wrapper}
|
|
106
123
|
);
|
|
107
124
|
|
|
108
125
|
expect(root.getByText('Good')).toBeTruthy();
|
|
109
126
|
expect(root.getByText('100')).toBeTruthy();
|
|
110
|
-
expect(root.getByText('2 audits passed
|
|
111
|
-
expect(root.getByText('
|
|
127
|
+
expect(root.getByText('2 audits passed')).toBeTruthy();
|
|
128
|
+
expect(root.getByText('2 passable audits')).toBeTruthy();
|
|
129
|
+
expect(root.getByText('1 informative audit')).toBeTruthy();
|
|
130
|
+
expect(root.getByText('https://example.com')).toBeTruthy();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('renders highest impact audits', async () => {
|
|
134
|
+
const category: any = {
|
|
135
|
+
id: 'seo',
|
|
136
|
+
score: 1,
|
|
137
|
+
auditRefs: [
|
|
138
|
+
/* eslint-disable max-len */
|
|
139
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'group'},
|
|
140
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 2, group: 'group'},
|
|
141
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 3, group: 'group'},
|
|
142
|
+
/* eslint-enable max-len */
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const root = render(
|
|
147
|
+
<SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
|
|
148
|
+
{wrapper}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const audits = root.getAllByText(/^Audit [0-9]$/);
|
|
152
|
+
|
|
153
|
+
expect(root.getByText('Highest impact')).toBeTruthy();
|
|
154
|
+
expect(audits.map(a => a.textContent)).toEqual([
|
|
155
|
+
'Audit 3',
|
|
156
|
+
'Audit 2',
|
|
157
|
+
]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('renders highest impact audits in performance', async () => {
|
|
161
|
+
const category: any = {
|
|
162
|
+
id: 'performance',
|
|
163
|
+
score: 0.75,
|
|
164
|
+
auditRefs: [
|
|
165
|
+
/* eslint-disable max-len */
|
|
166
|
+
{result: {score: 0.75, scoreDisplayMode: 'numeric', title: 'Metric 1'}, weight: 1, group: 'metrics'},
|
|
167
|
+
{result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 1', details: {type: 'opportunity', overallSavingsMs: 500}}, weight: 0, group: 'opportunities'},
|
|
168
|
+
{result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 2', details: {type: 'opportunity', overallSavingsMs: 1000}}, weight: 0, group: 'opportunities'},
|
|
169
|
+
{result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 3', details: {type: 'opportunity', overallSavingsMs: 100}}, weight: 0, group: 'opportunities'},
|
|
170
|
+
/* eslint-enable max-len */
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const root = render(
|
|
175
|
+
<SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
|
|
176
|
+
{wrapper}
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const audits = root.getAllByText(/^(Audit|Metric) [0-9]$/);
|
|
180
|
+
|
|
181
|
+
expect(root.getByText('Highest impact')).toBeTruthy();
|
|
182
|
+
expect(audits.map(a => a.textContent)).toEqual([
|
|
183
|
+
'Audit 2',
|
|
184
|
+
'Audit 1',
|
|
185
|
+
]);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('hides highest impact if nothing to show', async () => {
|
|
189
|
+
const category: any = {
|
|
190
|
+
id: 'performance',
|
|
191
|
+
score: 1,
|
|
192
|
+
auditRefs: [
|
|
193
|
+
/* eslint-disable max-len */
|
|
194
|
+
{result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
|
|
195
|
+
{result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'hidden'},
|
|
196
|
+
{result: {score: null, scoreDisplayMode: 'informative', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
|
|
197
|
+
/* eslint-enable max-len */
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const root = render(
|
|
202
|
+
<SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
|
|
203
|
+
{wrapper}
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
expect(() => root.getByText('Highest impact')).toThrow();
|
|
207
|
+
expect(() => root.getByText(/^Audit [0-9]$/)).toThrow();
|
|
112
208
|
});
|
|
113
209
|
});
|
|
@@ -34,7 +34,7 @@ describe('SummaryHeader', () => {
|
|
|
34
34
|
const lhrCounts = root.getByText(/·/);
|
|
35
35
|
expect(root.getByText('Summary')).toBeTruthy();
|
|
36
36
|
expect(lhrCounts.textContent).toEqual(
|
|
37
|
-
'2 navigation reports · 1 timespan
|
|
37
|
+
'2 navigation reports · 1 timespan report · 1 snapshot report'
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -9,7 +9,7 @@ import {renderHook} from '@testing-library/preact-hooks';
|
|
|
9
9
|
import {FunctionComponent} from 'preact';
|
|
10
10
|
import {act} from 'preact/test-utils';
|
|
11
11
|
|
|
12
|
-
import {FlowResultContext,
|
|
12
|
+
import {FlowResultContext, useHashState} from '../src/util';
|
|
13
13
|
import {flowResult} from './sample-flow';
|
|
14
14
|
|
|
15
15
|
let wrapper: FunctionComponent;
|
|
@@ -21,54 +21,75 @@ beforeEach(() => {
|
|
|
21
21
|
);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
describe('
|
|
24
|
+
describe('useHashState', () => {
|
|
25
25
|
it('gets current lhr index from url hash', () => {
|
|
26
26
|
global.location.hash = '#index=1';
|
|
27
|
-
const {result} = renderHook(() =>
|
|
27
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
28
28
|
expect(console.warn).not.toHaveBeenCalled();
|
|
29
29
|
expect(result.current).toEqual({
|
|
30
30
|
index: 1,
|
|
31
|
-
|
|
31
|
+
currentLhr: flowResult.steps[1].lhr,
|
|
32
|
+
anchor: null,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('gets anchor id from url hash', () => {
|
|
37
|
+
global.location.hash = '#index=1&anchor=seo';
|
|
38
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
39
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
40
|
+
expect(result.current).toEqual({
|
|
41
|
+
index: 1,
|
|
42
|
+
currentLhr: flowResult.steps[1].lhr,
|
|
43
|
+
anchor: 'seo',
|
|
32
44
|
});
|
|
33
45
|
});
|
|
34
46
|
|
|
35
47
|
it('changes on navigation', async () => {
|
|
36
48
|
global.location.hash = '#index=1';
|
|
37
|
-
const render = renderHook(() =>
|
|
49
|
+
const render = renderHook(() => useHashState(), {wrapper});
|
|
38
50
|
|
|
39
51
|
expect(render.result.current).toEqual({
|
|
40
52
|
index: 1,
|
|
41
|
-
|
|
53
|
+
currentLhr: flowResult.steps[1].lhr,
|
|
54
|
+
anchor: null,
|
|
42
55
|
});
|
|
43
56
|
|
|
44
57
|
await act(() => {
|
|
45
|
-
global.location.hash = '#index=2';
|
|
58
|
+
global.location.hash = '#index=2&anchor=seo';
|
|
46
59
|
});
|
|
47
60
|
await render.waitForNextUpdate();
|
|
48
61
|
|
|
49
62
|
expect(console.warn).not.toHaveBeenCalled();
|
|
50
63
|
expect(render.result.current).toEqual({
|
|
51
64
|
index: 2,
|
|
52
|
-
|
|
65
|
+
currentLhr: flowResult.steps[2].lhr,
|
|
66
|
+
anchor: 'seo',
|
|
53
67
|
});
|
|
54
68
|
});
|
|
55
69
|
|
|
56
70
|
it('return null if lhr index is unset', () => {
|
|
57
|
-
const {result} = renderHook(() =>
|
|
71
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
58
72
|
expect(console.warn).not.toHaveBeenCalled();
|
|
59
73
|
expect(result.current).toBeNull();
|
|
60
74
|
});
|
|
61
75
|
|
|
62
76
|
it('return null if lhr index is out of bounds', () => {
|
|
63
77
|
global.location.hash = '#index=5';
|
|
64
|
-
const {result} = renderHook(() =>
|
|
78
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
65
79
|
expect(console.warn).toHaveBeenCalled();
|
|
66
80
|
expect(result.current).toBeNull();
|
|
67
81
|
});
|
|
68
82
|
|
|
69
83
|
it('returns null for invalid value', () => {
|
|
70
84
|
global.location.hash = '#index=OHNO';
|
|
71
|
-
const {result} = renderHook(() =>
|
|
85
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
86
|
+
expect(console.warn).toHaveBeenCalled();
|
|
87
|
+
expect(result.current).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('returns null for invalid value with valid anchor', () => {
|
|
91
|
+
global.location.hash = '#index=OHNO&anchor=seo';
|
|
92
|
+
const {result} = renderHook(() => useHashState(), {wrapper});
|
|
72
93
|
expect(console.warn).toHaveBeenCalled();
|
|
73
94
|
expect(result.current).toBeNull();
|
|
74
95
|
});
|
|
@@ -0,0 +1,87 @@
|
|
|
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 {FunctionComponent} from 'preact';
|
|
8
|
+
import {render} from '@testing-library/preact';
|
|
9
|
+
|
|
10
|
+
import {CategoryScore} from '../../src/wrappers/category-score';
|
|
11
|
+
import {FlowResultContext} from '../../src/util';
|
|
12
|
+
import {ReportRendererProvider} from '../../src/wrappers/report-renderer';
|
|
13
|
+
import {I18nProvider} from '../../src/i18n/i18n';
|
|
14
|
+
import {flowResult} from '../sample-flow';
|
|
15
|
+
|
|
16
|
+
let wrapper: FunctionComponent;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
wrapper = ({children}) => (
|
|
20
|
+
<FlowResultContext.Provider value={flowResult}>
|
|
21
|
+
<ReportRendererProvider>
|
|
22
|
+
<I18nProvider>
|
|
23
|
+
{children}
|
|
24
|
+
</I18nProvider>
|
|
25
|
+
</ReportRendererProvider>
|
|
26
|
+
</FlowResultContext.Provider>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('CategoryScore', () => {
|
|
31
|
+
it('renders score gauge', () => {
|
|
32
|
+
const category: any = {
|
|
33
|
+
id: 'seo',
|
|
34
|
+
score: 0.95,
|
|
35
|
+
auditRefs: [],
|
|
36
|
+
};
|
|
37
|
+
const root = render(
|
|
38
|
+
<CategoryScore category={category} href="#seo" gatherMode="navigation"/>,
|
|
39
|
+
{wrapper}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const link = root.getByRole('link') as HTMLAnchorElement;
|
|
43
|
+
|
|
44
|
+
expect(link.href).toEqual('file:///Users/example/report.html/#seo');
|
|
45
|
+
expect(root.getByText('95')).toBeTruthy();
|
|
46
|
+
expect(root.baseElement.querySelector('.lh-gauge__label')).toBeFalsy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('renders error gauge', () => {
|
|
50
|
+
const category: any = {
|
|
51
|
+
id: 'seo',
|
|
52
|
+
score: null,
|
|
53
|
+
auditRefs: [],
|
|
54
|
+
};
|
|
55
|
+
const root = render(
|
|
56
|
+
<CategoryScore category={category} href="#seo" gatherMode="navigation"/>,
|
|
57
|
+
{wrapper}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const link = root.getByRole('link') as HTMLAnchorElement;
|
|
61
|
+
|
|
62
|
+
expect(link.href).toEqual('file:///Users/example/report.html/#seo');
|
|
63
|
+
expect(root.getByText('?')).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('renders category fraction', () => {
|
|
67
|
+
const category: any = {
|
|
68
|
+
id: 'seo',
|
|
69
|
+
auditRefs: [
|
|
70
|
+
{weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
|
|
71
|
+
{weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
|
|
72
|
+
{weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}},
|
|
73
|
+
{weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
const root = render(
|
|
77
|
+
<CategoryScore category={category} href="#seo" gatherMode="timespan"/>,
|
|
78
|
+
{wrapper}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const link = root.getByRole('link') as HTMLAnchorElement;
|
|
82
|
+
|
|
83
|
+
expect(link.href).toEqual('file:///Users/example/report.html/#seo');
|
|
84
|
+
expect(root.getByText('2/4')).toBeTruthy();
|
|
85
|
+
expect(root.baseElement.querySelector('.lh-fraction__label')).toBeFalsy();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 {render} from '@testing-library/preact';
|
|
8
|
+
import {FunctionComponent} from 'preact';
|
|
9
|
+
|
|
10
|
+
import {Markdown} from '../../src/wrappers/markdown';
|
|
11
|
+
import {ReportRendererProvider} from '../../src/wrappers/report-renderer';
|
|
12
|
+
|
|
13
|
+
let wrapper: FunctionComponent;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
wrapper = ({children}) => (
|
|
17
|
+
<ReportRendererProvider>
|
|
18
|
+
{children}
|
|
19
|
+
</ReportRendererProvider>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('Markdown', () => {
|
|
24
|
+
it('renders markdown text', () => {
|
|
25
|
+
const root = render(<Markdown text="Some `fancy` text"/>, {wrapper});
|
|
26
|
+
const text = root.getByText(/^Some.*text$/);
|
|
27
|
+
expect(text.innerHTML).toEqual('Some <code>fancy</code> text');
|
|
28
|
+
});
|
|
29
|
+
});
|
package/jest.config.js
CHANGED
|
@@ -13,12 +13,14 @@ module.exports = {
|
|
|
13
13
|
'**/lighthouse-cli/**/*-test.js',
|
|
14
14
|
'**/report/**/*-test.js',
|
|
15
15
|
'**/lighthouse-core/test/fraggle-rock/**/*-test-pptr.js',
|
|
16
|
-
'**/
|
|
17
|
-
'**/
|
|
16
|
+
'**/treemap/**/*-test.js',
|
|
17
|
+
'**/viewer/**/*-test.js',
|
|
18
18
|
'**/third-party/**/*-test.js',
|
|
19
19
|
'**/clients/test/**/*-test.js',
|
|
20
20
|
'**/shared/**/*-test.js',
|
|
21
|
+
'**/build/**/*-test.js',
|
|
21
22
|
],
|
|
23
|
+
modulePathIgnorePatterns: ['<rootDir>/.tmp'],
|
|
22
24
|
transform: {},
|
|
23
25
|
prettierPath: null,
|
|
24
26
|
projects: [
|
package/lighthouse-cli/run.js
CHANGED
|
@@ -175,7 +175,7 @@ async function potentiallyKillChrome(launchedChrome) {
|
|
|
175
175
|
/** @type {NodeJS.Timeout} */
|
|
176
176
|
let timeout;
|
|
177
177
|
const timeoutPromise = new Promise((_, reject) => {
|
|
178
|
-
timeout = setTimeout(
|
|
178
|
+
timeout = setTimeout(reject, 5000, new Error('Timed out waiting to kill Chrome'));
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
return Promise.race([
|
|
File without changes
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
* Currently uses `lighthouse-dt-bundle.js`.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import fs from 'fs';
|
|
15
|
+
|
|
14
16
|
import ChromeLauncher from 'chrome-launcher';
|
|
15
17
|
|
|
16
18
|
import ChromeProtocol from '../../../../lighthouse-core/gather/connections/cri.js';
|
|
19
|
+
import {LH_ROOT} from '../../../../root.js';
|
|
17
20
|
|
|
18
21
|
const originalRequire = global.require;
|
|
19
22
|
if (typeof globalThis === 'undefined') {
|
|
@@ -22,8 +25,7 @@ if (typeof globalThis === 'undefined') {
|
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
// Load bundle, which creates a `global.runBundledLighthouse`.
|
|
25
|
-
|
|
26
|
-
import '../../../../dist/lighthouse-dt-bundle.js'; // eslint-disable-line
|
|
28
|
+
eval(fs.readFileSync(LH_ROOT + '/dist/lighthouse-dt-bundle.js', 'utf-8'));
|
|
27
29
|
|
|
28
30
|
global.require = originalRequire;
|
|
29
31
|
|
|
@@ -39,7 +39,7 @@ async function runLighthouse(url, configJson, testRunnerOptions = {}) {
|
|
|
39
39
|
const tmpPath = await fs.mkdtemp(`${tmpDir}/smokehouse-`);
|
|
40
40
|
return internalRun(url, tmpPath, configJson, testRunnerOptions)
|
|
41
41
|
// Wait for internalRun() before removing scratch directory.
|
|
42
|
-
.finally(() => !isDebug && fs.
|
|
42
|
+
.finally(() => !isDebug && fs.rm(tmpPath, {recursive: true, force: true}));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -79,12 +79,18 @@ class AxeAudit extends Audit {
|
|
|
79
79
|
...Audit.makeNodeItem(axeNode.node),
|
|
80
80
|
explanation: axeNode.failureSummary,
|
|
81
81
|
},
|
|
82
|
+
subItems: axeNode.relatedNodes.length ? {
|
|
83
|
+
type: 'subitems',
|
|
84
|
+
items: axeNode.relatedNodes.map(node => ({relatedNode: Audit.makeNodeItem(node)})),
|
|
85
|
+
} : undefined,
|
|
82
86
|
}));
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
/** @type {LH.Audit.Details.Table['headings']} */
|
|
86
90
|
const headings = [
|
|
87
|
-
|
|
91
|
+
/* eslint-disable max-len */
|
|
92
|
+
{key: 'node', itemType: 'node', subItemsHeading: {key: 'relatedNode', itemType: 'node'}, text: str_(UIStrings.failingElementsHeader)},
|
|
93
|
+
/* eslint-enable max-len */
|
|
88
94
|
];
|
|
89
95
|
|
|
90
96
|
/** @type {LH.Audit.Details.DebugData|undefined} */
|
|
@@ -206,6 +206,8 @@ class UnusedBytes extends Audit {
|
|
|
206
206
|
*/
|
|
207
207
|
static computeWastedMsWithThroughput(wastedBytes, simulator) {
|
|
208
208
|
const bitsPerSecond = simulator.getOptions().throughput;
|
|
209
|
+
// https://github.com/GoogleChrome/lighthouse/pull/13323#issuecomment-962031709
|
|
210
|
+
if (bitsPerSecond === 0) return 0;
|
|
209
211
|
const wastedBits = wastedBytes * 8;
|
|
210
212
|
const wastedMs = wastedBits / bitsPerSecond * 1000;
|
|
211
213
|
return wastedMs;
|
|
@@ -103,6 +103,8 @@ class ModernImageFormats extends ByteEfficiencyAudit {
|
|
|
103
103
|
const items = [];
|
|
104
104
|
const warnings = [];
|
|
105
105
|
for (const image of images) {
|
|
106
|
+
const imageElement = imageElementsByURL.get(image.url);
|
|
107
|
+
|
|
106
108
|
if (image.failed) {
|
|
107
109
|
warnings.push(`Unable to decode ${URL.getURLDisplayName(image.url)}`);
|
|
108
110
|
continue;
|
|
@@ -120,7 +122,6 @@ class ModernImageFormats extends ByteEfficiencyAudit {
|
|
|
120
122
|
let fromProtocol = true;
|
|
121
123
|
|
|
122
124
|
if (typeof webpSize === 'undefined') {
|
|
123
|
-
const imageElement = imageElementsByURL.get(image.url);
|
|
124
125
|
if (!imageElement) {
|
|
125
126
|
warnings.push(`Unable to locate resource ${URL.getURLDisplayName(image.url)}`);
|
|
126
127
|
continue;
|
|
@@ -155,6 +156,7 @@ class ModernImageFormats extends ByteEfficiencyAudit {
|
|
|
155
156
|
const isCrossOrigin = !URL.originsMatch(pageURL, image.url);
|
|
156
157
|
|
|
157
158
|
items.push({
|
|
159
|
+
node: imageElement ? ByteEfficiencyAudit.makeNodeItem(imageElement.node) : undefined,
|
|
158
160
|
url,
|
|
159
161
|
fromProtocol,
|
|
160
162
|
isCrossOrigin,
|
|
@@ -166,7 +168,7 @@ class ModernImageFormats extends ByteEfficiencyAudit {
|
|
|
166
168
|
|
|
167
169
|
/** @type {LH.Audit.Details.Opportunity['headings']} */
|
|
168
170
|
const headings = [
|
|
169
|
-
{key: '
|
|
171
|
+
{key: 'node', valueType: 'node', label: ''},
|
|
170
172
|
{key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)},
|
|
171
173
|
{key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnResourceSize)},
|
|
172
174
|
{key: 'wastedBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnWastedBytes)},
|