lighthouse 8.6.0-dev.20211021 → 8.6.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/flow.js +13 -30
- package/dist/report/standalone.js +17 -17
- package/flow-report/assets/styles.css +30 -51
- package/flow-report/src/common.tsx +1 -1
- package/flow-report/src/header.tsx +2 -2
- package/flow-report/src/help-dialog.tsx +3 -3
- package/flow-report/src/i18n/i18n.tsx +13 -50
- package/flow-report/src/i18n/ui-strings.js +0 -48
- package/flow-report/src/icons.tsx +0 -7
- package/flow-report/src/sidebar/sidebar.tsx +6 -8
- package/flow-report/src/summary/category.tsx +18 -17
- package/flow-report/src/summary/summary.tsx +10 -10
- package/flow-report/src/topbar.tsx +5 -9
- package/flow-report/src/util.ts +5 -0
- package/flow-report/src/wrappers/category-score.tsx +3 -0
- package/flow-report/test/common-test.tsx +1 -1
- package/flow-report/test/summary/category-test.tsx +5 -9
- package/flow-report/test/summary/summary-test.tsx +1 -1
- package/flow-report/test/topbar-test.tsx +0 -1
- package/flow-report/tsconfig.json +0 -1
- package/jest.config.js +0 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
- package/lighthouse-core/audits/accessibility/axe-audit.js +1 -7
- package/lighthouse-core/audits/redirects-http.js +59 -0
- package/lighthouse-core/config/config-helpers.js +0 -1
- package/lighthouse-core/config/default-config.js +11 -0
- package/lighthouse-core/fraggle-rock/config/config.js +1 -1
- package/lighthouse-core/gather/gatherers/accessibility.js +0 -27
- package/lighthouse-core/gather/gatherers/http-redirect.js +46 -0
- package/lighthouse-core/lib/asset-saver.js +3 -3
- package/lighthouse-core/lib/i18n/i18n.js +8 -19
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +6699 -0
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +6672 -0
- package/lighthouse-core/util-commonjs.js +37 -25
- package/package.json +4 -8
- package/readme.md +3 -3
- package/report/assets/styles.css +28 -157
- package/report/assets/templates.html +47 -2
- package/report/clients/psi.js +158 -0
- package/report/renderer/category-renderer.js +1 -30
- package/report/renderer/components.js +34 -16
- package/report/renderer/performance-category-renderer.js +10 -5
- package/report/renderer/report-renderer.js +33 -56
- package/report/renderer/util.js +37 -25
- package/report/test/clients/psi-test.js +143 -0
- package/report/test/renderer/category-renderer-test.js +1 -5
- package/report/test/renderer/i18n-test.js +7 -0
- package/report/test/renderer/performance-category-renderer-test.js +1 -1
- package/report/test/renderer/pwa-category-renderer-test.js +2 -2
- package/report/test/renderer/report-renderer-axe-test.js +10 -5
- package/report/test/renderer/report-renderer-test.js +11 -9
- package/report/test-assets/faux-psi-template.html +4 -1
- package/report/test-assets/faux-psi.js +16 -39
- package/shared/localization/format.js +17 -50
- package/shared/localization/locales/ar-XB.json +24 -0
- package/shared/localization/locales/ar.json +24 -0
- package/shared/localization/locales/bg.json +24 -0
- package/shared/localization/locales/ca.json +24 -0
- package/shared/localization/locales/cs.json +24 -0
- package/shared/localization/locales/da.json +24 -0
- package/shared/localization/locales/de.json +24 -0
- package/shared/localization/locales/el.json +24 -0
- package/shared/localization/locales/en-GB.json +24 -0
- package/shared/localization/locales/en-US.ctc.json +6877 -0
- package/shared/localization/locales/en-US.json +23 -26
- package/shared/localization/locales/en-XA.json +24 -0
- package/shared/localization/locales/en-XL.ctc.json +6852 -0
- package/shared/localization/locales/en-XL.json +23 -26
- package/shared/localization/locales/es-419.json +24 -0
- package/shared/localization/locales/es.json +24 -0
- package/shared/localization/locales/fi.json +24 -0
- package/shared/localization/locales/fil.json +24 -0
- package/shared/localization/locales/fr.json +24 -0
- package/shared/localization/locales/he.json +24 -0
- package/shared/localization/locales/hi.json +24 -0
- package/shared/localization/locales/hr.json +24 -0
- package/shared/localization/locales/hu.json +24 -0
- package/shared/localization/locales/id.json +24 -0
- package/shared/localization/locales/it.json +24 -0
- package/shared/localization/locales/ja.json +24 -0
- package/shared/localization/locales/ko.json +24 -0
- package/shared/localization/locales/lt.json +24 -0
- package/shared/localization/locales/lv.json +24 -0
- package/shared/localization/locales/nl.json +24 -0
- package/shared/localization/locales/no.json +24 -0
- package/shared/localization/locales/pl.json +24 -0
- package/shared/localization/locales/pt-PT.json +24 -0
- package/shared/localization/locales/pt.json +24 -0
- package/shared/localization/locales/ro.json +24 -0
- package/shared/localization/locales/ru.json +24 -0
- package/shared/localization/locales/sk.json +24 -0
- package/shared/localization/locales/sl.json +24 -0
- package/shared/localization/locales/sr-Latn.json +24 -0
- package/shared/localization/locales/sr.json +24 -0
- package/shared/localization/locales/sv.json +24 -0
- package/shared/localization/locales/ta.json +24 -0
- package/shared/localization/locales/te.json +24 -0
- package/shared/localization/locales/th.json +24 -0
- package/shared/localization/locales/tr.json +24 -0
- package/shared/localization/locales/uk.json +24 -0
- package/shared/localization/locales/vi.json +24 -0
- package/shared/localization/locales/zh-HK.json +24 -0
- package/shared/localization/locales/zh-TW.json +24 -0
- package/shared/localization/locales/zh.json +24 -0
- package/shared/localization/locales.js +0 -6
- package/shared/test/localization/format-test.js +9 -45
- package/shared/test/localization/swap-locale-test.js +12 -0
- package/third-party/download-content-shell/download-content-shell.js +2 -2
- package/third-party/download-content-shell/utils.js +24 -0
- package/tsconfig.json +1 -0
- package/types/artifacts.d.ts +3 -1
- package/types/enquirer.d.ts +1 -3
- package/types/node.d.ts +5 -5
- package/flow-report/test/wrappers/category-score-test.tsx +0 -87
- package/report/test/clients/bundle-test.js +0 -62
|
@@ -9,54 +9,10 @@ const path = require('path');
|
|
|
9
9
|
|
|
10
10
|
const format = require('../../localization/format.js');
|
|
11
11
|
const i18n = require('../../../lighthouse-core/lib/i18n/i18n.js');
|
|
12
|
-
const constants = require('../../../lighthouse-core/config/constants.js');
|
|
13
|
-
const locales = require('../../localization/locales.js');
|
|
14
12
|
|
|
15
13
|
/* eslint-env jest */
|
|
16
14
|
|
|
17
15
|
describe('format', () => {
|
|
18
|
-
describe('DEFAULT_LOCALE', () => {
|
|
19
|
-
it('is the same as the default config locale', () => {
|
|
20
|
-
expect(format.DEFAULT_LOCALE).toBe(constants.defaultSettings.locale);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('#getAvailableLocales', () => {
|
|
25
|
-
it('has all the available locales', () => {
|
|
26
|
-
const availableLocales = format.getAvailableLocales();
|
|
27
|
-
for (const locale of ['en', 'es', 'ru', 'zh']) {
|
|
28
|
-
expect(availableLocales).toContain(locale);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const rawLocales = Object.keys(locales).sort();
|
|
32
|
-
expect(availableLocales.sort()).toEqual(rawLocales);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('contains the default locale', () => {
|
|
36
|
-
expect(format.getAvailableLocales()).toContain(format.DEFAULT_LOCALE);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('#getCanonicalLocales', () => {
|
|
41
|
-
it('contains some canonical locales', () => {
|
|
42
|
-
const canonicalLocales = format.getCanonicalLocales();
|
|
43
|
-
for (const locale of ['en-US', 'es', 'ru', 'zh']) {
|
|
44
|
-
expect(canonicalLocales).toContain(locale);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('is a subset of the available locales', () => {
|
|
49
|
-
const canonicalLocales = format.getCanonicalLocales();
|
|
50
|
-
const availableLocales = format.getAvailableLocales();
|
|
51
|
-
|
|
52
|
-
for (const canonicalLocale of canonicalLocales) {
|
|
53
|
-
expect(availableLocales).toContain(canonicalLocale);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
expect(canonicalLocales.length).toBeLessThan(availableLocales.length);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
16
|
describe('#_formatPathAsString', () => {
|
|
61
17
|
it('handles simple paths', () => {
|
|
62
18
|
expect(format._formatPathAsString(['foo'])).toBe('foo');
|
|
@@ -407,7 +363,15 @@ describe('format', () => {
|
|
|
407
363
|
expect(helloInfinityStr).toBeDisplayString('Hello ∞ World');
|
|
408
364
|
|
|
409
365
|
const helloNaNStr = str_(UIStrings.helloBytesWorld, {in: NaN});
|
|
410
|
-
|
|
366
|
+
// TODO(COMPAT): workaround can be removed after Node 13 is retired.
|
|
367
|
+
// expect(helloNaNStr).toBeDisplayString('Hello NaN World');
|
|
368
|
+
|
|
369
|
+
// Node 13/V8 7.9 and 8.0 have a bug where `({a: NaN}).a.toLocaleString() === "-NaN"`. It
|
|
370
|
+
// works correctly in Node 12 and 14, so work around it since NaN isn't essential for
|
|
371
|
+
// user-facing strings and it will eventually correct itself.
|
|
372
|
+
const formattedNaNStr = format.getFormatted(helloNaNStr, 'en-US');
|
|
373
|
+
expect(formattedNaNStr === 'Hello NaN World' || formattedNaNStr === 'Hello -NaN World')
|
|
374
|
+
.toBe(true);
|
|
411
375
|
});
|
|
412
376
|
});
|
|
413
377
|
});
|
|
@@ -6,11 +6,23 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const swapLocale = require('../../localization/swap-locale.js');
|
|
9
|
+
const {isNode12SmallIcu} = require('../../../lighthouse-core/test/test-utils.js');
|
|
9
10
|
|
|
10
11
|
const lhr = require('../../../lighthouse-core/test/results/sample_v2.json');
|
|
11
12
|
|
|
12
13
|
/* eslint-env jest */
|
|
13
14
|
describe('swap-locale', () => {
|
|
15
|
+
// COMPAT: Node 12 only has 'en' by default. Skip these tests since they're all about swapping locales.
|
|
16
|
+
if (isNode12SmallIcu()) {
|
|
17
|
+
// Jest requires at least one test per suite.
|
|
18
|
+
it('throws if locale is not supported', () => {
|
|
19
|
+
// Even though 'pt' is requested, 'en' is all that's available.
|
|
20
|
+
expect(() => swapLocale(lhr, 'pt')).toThrow('Unsupported locale \'pt\'');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
it('does not mutate the original lhr', () => {
|
|
15
27
|
/** @type {LH.Result} */
|
|
16
28
|
const lhrClone = JSON.parse(JSON.stringify(lhr));
|
|
@@ -85,7 +85,7 @@ function deleteOldContentShells() {
|
|
|
85
85
|
const remainingNumberOfContentShells = MAX_CONTENT_SHELLS / 2;
|
|
86
86
|
const oldContentShellDirs = files.slice(remainingNumberOfContentShells);
|
|
87
87
|
for (let i = 0; i < oldContentShellDirs.length; i++) {
|
|
88
|
-
|
|
88
|
+
utils.removeRecursive(path.resolve(CACHE_PATH, oldContentShellDirs[i]));
|
|
89
89
|
}
|
|
90
90
|
console.log(`Removed old content shells: ${oldContentShellDirs}`);
|
|
91
91
|
}
|
|
@@ -126,7 +126,7 @@ function findPreviousUploadedPosition(commitPosition) {
|
|
|
126
126
|
async function prepareContentShellDirectory(folder) {
|
|
127
127
|
const contentShellPath = path.join(CACHE_PATH, folder);
|
|
128
128
|
if (utils.isDir(contentShellPath)) {
|
|
129
|
-
|
|
129
|
+
utils.removeRecursive(contentShellPath);
|
|
130
130
|
}
|
|
131
131
|
fs.mkdirSync(contentShellPath);
|
|
132
132
|
return folder;
|
|
@@ -96,6 +96,29 @@ function copyRecursive(src, dest) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
function removeRecursive(filePath) {
|
|
100
|
+
try {
|
|
101
|
+
if (fs.existsSync(filePath)) {
|
|
102
|
+
if (isFile(filePath)) {
|
|
103
|
+
fs.unlinkSync(filePath);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const files = fs.readdirSync(filePath);
|
|
107
|
+
for (let i = 0; i < files.length; i++) {
|
|
108
|
+
const childPath = path.resolve(filePath, files[i]);
|
|
109
|
+
if (isDir(childPath)) {
|
|
110
|
+
removeRecursive(childPath);
|
|
111
|
+
} else {
|
|
112
|
+
fs.unlinkSync(childPath);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
fs.rmdirSync(filePath);
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw new Error(`Received an error: [${error}] while trying to remove: ${filePath}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
99
122
|
function includes(sequence, target) {
|
|
100
123
|
return sequence.indexOf(target) > -1;
|
|
101
124
|
}
|
|
@@ -122,6 +145,7 @@ module.exports = {
|
|
|
122
145
|
isDir,
|
|
123
146
|
copy,
|
|
124
147
|
copyRecursive,
|
|
148
|
+
removeRecursive,
|
|
125
149
|
includes,
|
|
126
150
|
shellOutput,
|
|
127
151
|
parseArgs,
|
package/tsconfig.json
CHANGED
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"lighthouse-core/test/gather/gatherers/full-page-screenshot-test.js",
|
|
59
59
|
"lighthouse-core/test/gather/gatherers/global-listeners-test.js",
|
|
60
60
|
"lighthouse-core/test/gather/gatherers/html-without-javascript-test.js",
|
|
61
|
+
"lighthouse-core/test/gather/gatherers/http-redirect-test.js",
|
|
61
62
|
"lighthouse-core/test/gather/gatherers/js-usage-test.js",
|
|
62
63
|
"lighthouse-core/test/gather/gatherers/link-elements-test.js",
|
|
63
64
|
"lighthouse-core/test/gather/gatherers/offline-test.js",
|
package/types/artifacts.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface Artifacts extends BaseArtifacts, GathererArtifacts {}
|
|
|
25
25
|
|
|
26
26
|
export type FRArtifacts = StrictOmit<Artifacts,
|
|
27
27
|
| 'Fonts'
|
|
28
|
+
| 'HTTPRedirect'
|
|
28
29
|
| 'Manifest'
|
|
29
30
|
| 'MixedContent'
|
|
30
31
|
| keyof FRBaseArtifacts
|
|
@@ -147,6 +148,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
|
|
|
147
148
|
FullPageScreenshot: Artifacts.FullPageScreenshot | null;
|
|
148
149
|
/** Information about event listeners registered on the global object. */
|
|
149
150
|
GlobalListeners: Array<Artifacts.GlobalListener>;
|
|
151
|
+
/** Whether the page ended up on an HTTPS page after attempting to load the HTTP version. */
|
|
152
|
+
HTTPRedirect: {value: boolean};
|
|
150
153
|
/** The issues surfaced in the devtools Issues panel */
|
|
151
154
|
InspectorIssues: Artifacts.InspectorIssues;
|
|
152
155
|
/** JS coverage information for code used during page load. Keyed by network URL. */
|
|
@@ -208,7 +211,6 @@ declare module Artifacts {
|
|
|
208
211
|
target: Array<string>;
|
|
209
212
|
failureSummary?: string;
|
|
210
213
|
node: NodeDetails;
|
|
211
|
-
relatedNodes: NodeDetails[];
|
|
212
214
|
}>;
|
|
213
215
|
error?: RuleExecutionError;
|
|
214
216
|
}
|
package/types/enquirer.d.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
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 {EventEmitter} from 'events';
|
|
8
|
-
|
|
9
7
|
declare module 'enquirer' {
|
|
10
8
|
interface ConfirmOption {
|
|
11
9
|
name: string | (() => string);
|
|
@@ -14,7 +12,7 @@ declare module 'enquirer' {
|
|
|
14
12
|
actions?: {'ctrl': {[key: string]: string}}
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
class Confirm extends EventEmitter {
|
|
15
|
+
class Confirm extends NodeJS.EventEmitter {
|
|
18
16
|
constructor(option: ConfirmOption);
|
|
19
17
|
run: () => Promise<boolean>;
|
|
20
18
|
close: () => Promise<void>
|
package/types/node.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
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
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare module NodeJS {
|
|
8
|
+
interface Global {
|
|
9
|
+
isDevtools?: boolean;
|
|
10
|
+
isLightrider?: boolean;
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
|
|
11
|
-
import jsdom from 'jsdom';
|
|
12
|
-
|
|
13
|
-
import * as lighthouseRenderer from '../../clients/bundle.js';
|
|
14
|
-
import {LH_ROOT} from '../../../root.js';
|
|
15
|
-
|
|
16
|
-
const sampleResultsStr =
|
|
17
|
-
fs.readFileSync(LH_ROOT + '/lighthouse-core/test/results/sample_v2.json', 'utf-8');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* eslint-env jest */
|
|
21
|
-
|
|
22
|
-
describe('lighthouseRenderer bundle', () => {
|
|
23
|
-
let document;
|
|
24
|
-
beforeAll(() => {
|
|
25
|
-
const {window} = new jsdom.JSDOM();
|
|
26
|
-
document = window.document;
|
|
27
|
-
|
|
28
|
-
global.window = global.self = window;
|
|
29
|
-
// Stub out matchMedia for Node.
|
|
30
|
-
global.self.matchMedia = function() {
|
|
31
|
-
return {
|
|
32
|
-
addListener: function() {},
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterAll(() => {
|
|
38
|
-
global.window = global.self = undefined;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it('renders an LHR to DOM', () => {
|
|
43
|
-
const lhr = /** @type {LH.Result} */ JSON.parse(sampleResultsStr);
|
|
44
|
-
const reportContainer = document.body;
|
|
45
|
-
reportContainer.classList.add('lh-vars', 'lh-root');
|
|
46
|
-
|
|
47
|
-
const dom = new lighthouseRenderer.DOM(reportContainer.ownerDocument);
|
|
48
|
-
const renderer = new lighthouseRenderer.ReportRenderer(dom);
|
|
49
|
-
renderer.renderReport(lhr, reportContainer);
|
|
50
|
-
const features = new lighthouseRenderer.ReportUIFeatures(renderer._dom);
|
|
51
|
-
features.initFeatures(lhr);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Check that the report exists and has some content.
|
|
55
|
-
expect(reportContainer instanceof document.defaultView.Element).toBeTruthy();
|
|
56
|
-
expect(reportContainer.outerHTML.length).toBeGreaterThan(50000);
|
|
57
|
-
|
|
58
|
-
const title = reportContainer.querySelector('.lh-audit-group--metrics')
|
|
59
|
-
.querySelector('.lh-audit-group__title');
|
|
60
|
-
expect(title.textContent).toEqual('Metrics');
|
|
61
|
-
});
|
|
62
|
-
});
|