lighthouse 10.0.0 → 10.0.1

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.
Files changed (69) hide show
  1. package/changelog-pre10.md +6085 -0
  2. package/core/audits/dobetterweb/doctype.d.ts +3 -2
  3. package/core/audits/dobetterweb/doctype.js +15 -4
  4. package/core/audits/dobetterweb/paste-preventing-inputs.js +2 -2
  5. package/core/gather/driver/network-monitor.js +1 -3
  6. package/core/gather/gatherers/bf-cache-failures.js +7 -8
  7. package/package.json +2 -2
  8. package/shared/localization/locales/en-US.json +1 -1
  9. package/shared/localization/locales/en-XL.json +1 -1
  10. package/.codecov.yml +0 -22
  11. package/.cz-config.js +0 -24
  12. package/.gitattributes +0 -5
  13. package/.mailmap +0 -6
  14. package/CODE_OF_CONDUCT.md +0 -93
  15. package/eslint-local-rules.cjs +0 -106
  16. package/flow-report/test/app-test.d.ts +0 -7
  17. package/flow-report/test/app-test.tsx +0 -52
  18. package/flow-report/test/common-test.d.ts +0 -7
  19. package/flow-report/test/common-test.tsx +0 -103
  20. package/flow-report/test/flow-report-pptr-test.d.ts +0 -7
  21. package/flow-report/test/flow-report-pptr-test.ts +0 -59
  22. package/flow-report/test/header-test.d.ts +0 -7
  23. package/flow-report/test/header-test.tsx +0 -55
  24. package/flow-report/test/run-flow-report-tests.sh +0 -20
  25. package/flow-report/test/sample-flow.d.ts +0 -7
  26. package/flow-report/test/sample-flow.ts +0 -17
  27. package/flow-report/test/setup/env-setup.d.ts +0 -11
  28. package/flow-report/test/setup/env-setup.ts +0 -55
  29. package/flow-report/test/sidebar/flow-test.d.ts +0 -7
  30. package/flow-report/test/sidebar/flow-test.tsx +0 -65
  31. package/flow-report/test/sidebar/sidebar-test.d.ts +0 -7
  32. package/flow-report/test/sidebar/sidebar-test.tsx +0 -116
  33. package/flow-report/test/summary/category-test.d.ts +0 -7
  34. package/flow-report/test/summary/category-test.tsx +0 -206
  35. package/flow-report/test/summary/summary-test.d.ts +0 -7
  36. package/flow-report/test/summary/summary-test.tsx +0 -124
  37. package/flow-report/test/topbar-test.d.ts +0 -7
  38. package/flow-report/test/topbar-test.tsx +0 -84
  39. package/flow-report/test/util-test.d.ts +0 -7
  40. package/flow-report/test/util-test.tsx +0 -133
  41. package/flow-report/test/wrappers/category-score-test.d.ts +0 -7
  42. package/flow-report/test/wrappers/category-score-test.tsx +0 -84
  43. package/flow-report/test/wrappers/markdown-test.d.ts +0 -7
  44. package/flow-report/test/wrappers/markdown-test.tsx +0 -17
  45. package/report/test/clients/bundle-test.js +0 -65
  46. package/report/test/generator/file-namer-test.js +0 -27
  47. package/report/test/generator/report-generator-test.js +0 -160
  48. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +0 -15
  49. package/report/test/renderer/category-renderer-test.js +0 -575
  50. package/report/test/renderer/components-test.js +0 -124
  51. package/report/test/renderer/crc-details-renderer-test.js +0 -116
  52. package/report/test/renderer/details-renderer-test.js +0 -882
  53. package/report/test/renderer/dom-test.js +0 -257
  54. package/report/test/renderer/element-screenshot-renderer-test.js +0 -183
  55. package/report/test/renderer/i18n-formatter-test.js +0 -179
  56. package/report/test/renderer/performance-category-renderer-test.js +0 -417
  57. package/report/test/renderer/pwa-category-renderer-test.js +0 -301
  58. package/report/test/renderer/report-renderer-axe-test.js +0 -85
  59. package/report/test/renderer/report-renderer-test.js +0 -268
  60. package/report/test/renderer/report-ui-features-test.js +0 -773
  61. package/report/test/renderer/report-utils-test.js +0 -219
  62. package/report/test/renderer/snippet-renderer-test.js +0 -291
  63. package/report/test/renderer/text-encoding-test.js +0 -43
  64. package/report/test-assets/faux-psi.d.ts +0 -34
  65. package/shared/test/localization/format-test.js +0 -430
  66. package/shared/test/localization/locales-test.js +0 -45
  67. package/shared/test/localization/swap-locale-test.js +0 -127
  68. package/shared/test/util-test.js +0 -214
  69. package/vercel.json +0 -6
@@ -1,59 +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 puppeteer, {Browser, Page} from 'puppeteer';
8
-
9
- import {ReportGenerator} from '../../report/generator/report-generator.js';
10
- import {swapFlowLocale} from '../../shared/localization/swap-flow-locale.js';
11
- import {flowResult} from './sample-flow';
12
-
13
- describe('Lighthouse Flow Report', () => {
14
- console.log('\n✨ Be sure to have recently run this: yarn build-report');
15
-
16
- let browser: Browser;
17
- let page: Page;
18
- const pageErrors: Error[] = [];
19
-
20
- before(async () => {
21
- browser = await puppeteer.launch({
22
- headless: true,
23
- });
24
- page = await browser.newPage();
25
- page.on('pageerror', pageError => pageErrors.push(pageError));
26
- });
27
-
28
- after(async () => {
29
- if (pageErrors.length > 0) console.error(pageErrors);
30
-
31
- await browser.close();
32
- });
33
-
34
- describe('Renders the flow report', () => {
35
- before(async () => {
36
- const html = ReportGenerator.generateFlowReportHtml(flowResult);
37
- await page.setContent(html);
38
- });
39
-
40
- it('should load with no errors', async () => {
41
- expect(pageErrors).toHaveLength(0);
42
- });
43
- });
44
-
45
- describe('Renders the flow report (i18n)', () => {
46
- before(async () => {
47
- const html = ReportGenerator.generateFlowReportHtml(swapFlowLocale(flowResult, 'es'));
48
- await page.setContent(html);
49
- });
50
-
51
- it('should load with no errors', async () => {
52
- expect(pageErrors).toHaveLength(0);
53
- const el = await page.$('.SummarySectionHeader__content');
54
- if (!el) throw new Error();
55
- const text = await el.evaluate(el => el.textContent);
56
- expect(text).toEqual('Todos los informes');
57
- });
58
- });
59
- }).timeout(35_000);
@@ -1,7 +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
- export {};
7
- //# sourceMappingURL=header-test.d.ts.map
@@ -1,55 +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 {Header} from '../src/header';
11
- import {FlowResultContext} from '../src/util';
12
- import {flowResult} from './sample-flow';
13
- import {I18nProvider} from '../src/i18n/i18n';
14
-
15
- let wrapper: FunctionComponent;
16
-
17
- beforeEach(() => {
18
- wrapper = ({children}) => (
19
- <FlowResultContext.Provider value={flowResult}>
20
- <I18nProvider>
21
- {children}
22
- </I18nProvider>
23
- </FlowResultContext.Provider>
24
- );
25
- });
26
-
27
- it('renders all sections for a middle step', () => {
28
- const hashState = {index: 1} as any;
29
- const root = render(<Header hashState={hashState}/>, {wrapper});
30
-
31
- expect(root.baseElement.querySelector('.Header__prev-thumbnail')).toBeTruthy();
32
- expect(root.baseElement.querySelector('.Header__prev-title')).toBeTruthy();
33
- expect(root.baseElement.querySelector('.Header__next-thumbnail')).toBeTruthy();
34
- expect(root.baseElement.querySelector('.Header__next-title')).toBeTruthy();
35
- });
36
-
37
- it('renders only next section for first step', () => {
38
- const hashState = {index: 0} as any;
39
- const root = render(<Header hashState={hashState}/>, {wrapper});
40
-
41
- expect(root.baseElement.querySelector('.Header__prev-thumbnail')).toBeFalsy();
42
- expect(root.baseElement.querySelector('.Header__prev-title')).toBeFalsy();
43
- expect(root.baseElement.querySelector('.Header__next-thumbnail')).toBeTruthy();
44
- expect(root.baseElement.querySelector('.Header__next-title')).toBeTruthy();
45
- });
46
-
47
- it('renders only previous section for last step', () => {
48
- const hashState = {index: 3} as any;
49
- const root = render(<Header hashState={hashState}/>, {wrapper});
50
-
51
- expect(root.baseElement.querySelector('.Header__prev-thumbnail')).toBeTruthy();
52
- expect(root.baseElement.querySelector('.Header__prev-title')).toBeTruthy();
53
- expect(root.baseElement.querySelector('.Header__next-thumbnail')).toBeFalsy();
54
- expect(root.baseElement.querySelector('.Header__next-title')).toBeFalsy();
55
- });
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ##
4
- # @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
5
- # 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
6
- # 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.
7
- ##
8
-
9
- set -eux
10
-
11
- SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
12
- LH_ROOT="$SCRIPT_DIR/../.."
13
-
14
- ARGS=(
15
- --testMatch='{flow-report/**/*-test.ts,flow-report/**/*-test.tsx}'
16
- --require="$LH_ROOT/flow-report/test/setup/env-setup.ts"
17
- )
18
-
19
- cd "$LH_ROOT"
20
- node --loader=@esbuild-kit/esm-loader core/test/scripts/run-mocha-tests.js ${ARGS[*]} "$@"
@@ -1,7 +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
- export declare const flowResult: LH.FlowResult;
7
- //# sourceMappingURL=sample-flow.d.ts.map
@@ -1,17 +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 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))}/../../core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`,
15
- 'utf-8'
16
- )
17
- );
@@ -1,11 +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
- declare const rootHooks: {
7
- beforeAll(): void;
8
- beforeEach(): void;
9
- };
10
- export { rootHooks, };
11
- //# sourceMappingURL=env-setup.d.ts.map
@@ -1,55 +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 fs from 'fs';
8
- import {MessageChannel} from 'worker_threads';
9
-
10
- import jestMock from 'jest-mock';
11
- import {JSDOM} from 'jsdom';
12
- import * as preact from 'preact';
13
-
14
- import {LH_ROOT} from '../../../root.js';
15
-
16
- // These modules aren't imported correctly if these directories aren't defined to use ES modules.
17
- // Similar to this, which was resolved but their fix didn't work for us:
18
- // https://github.com/testing-library/preact-testing-library/issues/36#issuecomment-1136484478
19
- fs.writeFileSync(`${LH_ROOT}/node_modules/@testing-library/preact/dist/esm/package.json`,
20
- '{"type": "module"}');
21
- fs.writeFileSync(`${LH_ROOT}/node_modules/@testing-library/preact-hooks/src/package.json`,
22
- '{"type": "module"}');
23
-
24
- const rootHooks = {
25
- beforeAll() {
26
- // @ts-expect-error
27
- global.React = preact;
28
- },
29
- beforeEach() {
30
- const {window} = new JSDOM(undefined, {
31
- url: 'file:///Users/example/report.html/',
32
- });
33
- global.window = window as any;
34
- global.document = window.document;
35
- global.location = window.location;
36
- global.self = global.window;
37
-
38
- // Use JSDOM types as necessary.
39
- global.Blob = window.Blob;
40
- global.HTMLInputElement = window.HTMLInputElement;
41
-
42
- // Functions not implemented in JSDOM.
43
- window.Element.prototype.scrollIntoView = jestMock.fn();
44
- global.self.matchMedia = jestMock.fn<any, any>(() => ({
45
- addListener: jestMock.fn(),
46
- }));
47
-
48
- // @ts-expect-error: for @testing-library/preact-hooks
49
- global.MessageChannel = MessageChannel;
50
- },
51
- };
52
-
53
- export {
54
- rootHooks,
55
- };
@@ -1,7 +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
- export {};
7
- //# sourceMappingURL=flow-test.d.ts.map
@@ -1,65 +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 {render} from '@testing-library/preact';
8
- import {FunctionComponent} from 'preact';
9
-
10
- import {SidebarFlow} from '../../src/sidebar/flow';
11
- import {FlowResultContext} from '../../src/util';
12
- import {flowResult} from '../sample-flow';
13
-
14
- let wrapper: FunctionComponent;
15
-
16
- beforeEach(() => {
17
- wrapper = ({children}) => (
18
- <FlowResultContext.Provider value={flowResult}>{children}</FlowResultContext.Provider>
19
- );
20
- });
21
-
22
- describe('SidebarFlow', () => {
23
- it('renders flow steps', async () => {
24
- const root = render(<SidebarFlow/>, {wrapper});
25
-
26
- const navigation = root.getByText('Navigation report (www.mikescerealshack.co/)');
27
- const timespan = root.getByText('Search input');
28
- const snapshot = root.getByText('Search results');
29
- const navigation2 = root.getByText('Navigation report (www.mikescerealshack.co/corrections)');
30
-
31
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
32
- expect(links.map(a => a.textContent)).toEqual([
33
- navigation.textContent,
34
- timespan.textContent,
35
- snapshot.textContent,
36
- navigation2.textContent,
37
- ]);
38
- expect(links.map(a => a.href)).toEqual([
39
- 'file:///Users/example/report.html/#index=0',
40
- 'file:///Users/example/report.html/#index=1',
41
- 'file:///Users/example/report.html/#index=2',
42
- 'file:///Users/example/report.html/#index=3',
43
- ]);
44
- });
45
-
46
- it('no steps highlighted on summary page', async () => {
47
- const root = render(<SidebarFlow/>, {wrapper});
48
-
49
- const links = root.getAllByRole('link');
50
- const highlighted = links.filter(h => h.classList.contains('Sidebar--current'));
51
-
52
- expect(highlighted).toHaveLength(0);
53
- });
54
-
55
- it('highlight current step', async () => {
56
- global.location.hash = '#index=1';
57
- const root = render(<SidebarFlow/>, {wrapper});
58
-
59
- const links = root.getAllByRole('link');
60
- const highlighted = links.filter(h => h.classList.contains('Sidebar--current'));
61
-
62
- expect(highlighted).toHaveLength(1);
63
- expect(links[1]).toEqual(highlighted[0]);
64
- });
65
- });
@@ -1,7 +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
- export {};
7
- //# sourceMappingURL=sidebar-test.d.ts.map
@@ -1,116 +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 {render} from '@testing-library/preact';
8
- import {FunctionComponent} from 'preact';
9
-
10
- import {I18nProvider} from '../../src/i18n/i18n';
11
- import {SidebarHeader, SidebarRuntimeSettings, SidebarSummary} from '../../src/sidebar/sidebar';
12
- import {FlowResultContext} from '../../src/util';
13
- import {flowResult} from '../sample-flow';
14
-
15
- let wrapper: FunctionComponent;
16
-
17
- beforeEach(() => {
18
- wrapper = ({children}) => (
19
- <FlowResultContext.Provider value={flowResult}>
20
- <I18nProvider>
21
- {children}
22
- </I18nProvider>
23
- </FlowResultContext.Provider>
24
- );
25
- });
26
-
27
- describe('SidebarHeader', () => {
28
- it('renders title content', async () => {
29
- const title = 'Lighthouse flow report';
30
- const date = '2021-08-03T18:28:13.296Z';
31
- const root = render(<SidebarHeader title={title} date={date}/>, {wrapper});
32
-
33
- expect(root.getByText(title)).toBeTruthy();
34
- expect(root.getByText('Aug 3, 2021, 6:28 PM UTC')).toBeTruthy();
35
- });
36
- });
37
-
38
- describe('SidebarSummary', () => {
39
- it('highlighted by default', async () => {
40
- const root = render(<SidebarSummary/>, {wrapper});
41
- const link = root.getByRole('link') as HTMLAnchorElement;
42
-
43
- expect(link.href).toEqual('file:///Users/example/report.html/#');
44
- expect(link.classList).toContain('Sidebar--current');
45
- });
46
- });
47
-
48
- describe('SidebarRuntimeSettings', () => {
49
- it('displays default runtime settings', async () => {
50
- const settings = {
51
- formFactor: 'mobile',
52
- throttlingMethod: 'simulate',
53
- throttling: {
54
- cpuSlowdownMultiplier: 4,
55
- requestLatencyMs: 150 * 3.75,
56
- downloadThroughputKbps: 1.6 * 1024 * 0.9,
57
- uploadThroughputKbps: 750 * 0.9,
58
- throughputKbps: 1.6 * 1024,
59
- rttMs: 150,
60
- },
61
- screenEmulation: {
62
- disabled: false,
63
- width: 200,
64
- height: 200,
65
- deviceScaleFactor: 3,
66
- mobile: true,
67
- },
68
- } as any;
69
- const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
70
-
71
- expect(root.getByText('Emulated Moto G Power - 200x200, DPR 3')).toBeTruthy();
72
- expect(root.queryByText('Emulated Moto G Power -')).toBeFalsy();
73
- expect(root.getByText('Slow 4G throttling')).toBeTruthy();
74
- expect(root.getByText('4x slowdown'));
75
- });
76
-
77
- it('displays custom runtime settings', async () => {
78
- const settings = {
79
- formFactor: 'desktop',
80
- throttlingMethod: 'devtools',
81
- throttling: {
82
- cpuSlowdownMultiplier: 1,
83
- requestLatencyMs: 1,
84
- downloadThroughputKbps: 1,
85
- uploadThroughputKbps: 1,
86
- throughputKbps: 1,
87
- rttMs: 1,
88
- },
89
- screenEmulation: {
90
- width: 100,
91
- height: 100,
92
- mobile: false,
93
- deviceScaleFactor: 2,
94
- },
95
- } as any;
96
- const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
97
-
98
- expect(root.getByText('Emulated Desktop - 100x100, DPR 2')).toBeTruthy();
99
- expect(root.getByText('Custom throttling')).toBeTruthy();
100
- expect(root.getByText('1x slowdown'));
101
- });
102
-
103
- it('displays runtime settings when screenEmulation disabled', async () => {
104
- const settings = {
105
- formFactor: 'mobile',
106
- throttlingMethod: 'provided',
107
- throttling: {},
108
- screenEmulation: {disabled: true},
109
- } as any;
110
- const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
111
-
112
- expect(root.getByText('No emulation')).toBeTruthy();
113
- expect(root.queryByText('Emulated Moto G Power -')).toBeFalsy();
114
- expect(root.getByText('Provided by environment')).toBeTruthy();
115
- });
116
- });
@@ -1,7 +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
- export {};
7
- //# sourceMappingURL=category-test.d.ts.map
@@ -1,206 +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 {SummaryTooltip} from '../../src/summary/category';
11
- import {flowResult} from '../sample-flow';
12
- import {I18nProvider} from '../../src/i18n/i18n';
13
- import {FlowResultContext} from '../../src/util';
14
-
15
- let wrapper: FunctionComponent;
16
-
17
- beforeEach(() => {
18
- // Include sample flowResult for locale in I18nProvider.
19
- wrapper = ({children}) => (
20
- <FlowResultContext.Provider value={flowResult}>
21
- <I18nProvider>
22
- {children}
23
- </I18nProvider>
24
- </FlowResultContext.Provider>
25
- );
26
- });
27
-
28
- describe('SummaryTooltip', () => {
29
- it('renders tooltip with rating', async () => {
30
- const category: any = {
31
- id: 'performance',
32
- score: 1,
33
- auditRefs: [
34
- /* eslint-disable max-len */
35
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
36
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
37
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
38
- /* eslint-enable max-len */
39
- ],
40
- };
41
-
42
- const root = render(
43
- <SummaryTooltip category={category} gatherMode="snapshot" url="https://example.com"/>,
44
- {wrapper}
45
- );
46
-
47
- expect(root.getByText('Average')).toBeTruthy();
48
- expect(() => root.getByText(/^[0-9]+$/)).toThrow();
49
- expect(root.getByText('2 audits passed')).toBeTruthy();
50
- expect(root.getByText('3 passable audits')).toBeTruthy();
51
- expect(root.getByText('https://example.com')).toBeTruthy();
52
- });
53
-
54
- it('renders tooltip without rating', async () => {
55
- const category: any = {
56
- id: 'performance',
57
- score: 1,
58
- auditRefs: [
59
- /* eslint-disable max-len */
60
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 0, group: 'diagnostics'},
61
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 0, group: 'diagnostics'},
62
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 0, group: 'diagnostics'},
63
- /* eslint-enable max-len */
64
- ],
65
- };
66
-
67
- const root = render(
68
- <SummaryTooltip category={category} gatherMode="snapshot" url="https://example.com"/>,
69
- {wrapper}
70
- );
71
-
72
- expect(() => root.getByText(/^(Average|Good|Poor)$/)).toThrow();
73
- expect(() => root.getByText(/^[0-9]+$/)).toThrow();
74
- expect(root.getByText('2 audits passed')).toBeTruthy();
75
- expect(root.getByText('3 passable audits')).toBeTruthy();
76
- expect(root.getByText('https://example.com')).toBeTruthy();
77
- });
78
-
79
- it('renders scored category tooltip with score', async () => {
80
- const category: any = {
81
- id: 'performance',
82
- score: 1,
83
- auditRefs: [
84
- /* eslint-disable max-len */
85
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
86
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
87
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
88
- /* eslint-enable max-len */
89
- ],
90
- };
91
-
92
- const root = render(
93
- <SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
94
- {wrapper}
95
- );
96
-
97
- expect(root.getByText('Good')).toBeTruthy();
98
- expect(root.getByText('100')).toBeTruthy();
99
- expect(root.getByText('2 audits passed')).toBeTruthy();
100
- expect(root.getByText('3 passable audits')).toBeTruthy();
101
- expect(root.getByText('https://example.com')).toBeTruthy();
102
- });
103
-
104
- it('renders informative audit count if any', async () => {
105
- const category: any = {
106
- id: 'performance',
107
- score: 1,
108
- auditRefs: [
109
- /* eslint-disable max-len */
110
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
111
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'diagnostics'},
112
- {result: {score: null, scoreDisplayMode: 'informative', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
113
- /* eslint-enable max-len */
114
- ],
115
- };
116
-
117
- const root = render(
118
- <SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
119
- {wrapper}
120
- );
121
-
122
- expect(root.getByText('Good')).toBeTruthy();
123
- expect(root.getByText('100')).toBeTruthy();
124
- expect(root.getByText('2 audits passed')).toBeTruthy();
125
- expect(root.getByText('2 passable audits')).toBeTruthy();
126
- expect(root.getByText('1 informative audit')).toBeTruthy();
127
- expect(root.getByText('https://example.com')).toBeTruthy();
128
- });
129
-
130
- it('renders highest impact audits', async () => {
131
- const category: any = {
132
- id: 'seo',
133
- score: 1,
134
- auditRefs: [
135
- /* eslint-disable max-len */
136
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'group'},
137
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 2, group: 'group'},
138
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 3'}, weight: 3, group: 'group'},
139
- /* eslint-enable max-len */
140
- ],
141
- };
142
-
143
- const root = render(
144
- <SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
145
- {wrapper}
146
- );
147
-
148
- const audits = root.getAllByText(/^Audit [0-9]$/);
149
-
150
- expect(root.getByText('Highest impact')).toBeTruthy();
151
- expect(audits.map(a => a.textContent)).toEqual([
152
- 'Audit 3',
153
- 'Audit 2',
154
- ]);
155
- });
156
-
157
- it('renders highest impact audits in performance', async () => {
158
- const category: any = {
159
- id: 'performance',
160
- score: 0.75,
161
- auditRefs: [
162
- /* eslint-disable max-len */
163
- {result: {score: 0.75, scoreDisplayMode: 'numeric', title: 'Metric 1'}, weight: 1, group: 'metrics'},
164
- {result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 1', details: {type: 'opportunity', overallSavingsMs: 500}}, weight: 0, group: 'opportunities'},
165
- {result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 2', details: {type: 'opportunity', overallSavingsMs: 1000}}, weight: 0, group: 'opportunities'},
166
- {result: {score: 0, scoreDisplayMode: 'numeric', title: 'Audit 3', details: {type: 'opportunity', overallSavingsMs: 100}}, weight: 0, group: 'opportunities'},
167
- /* eslint-enable max-len */
168
- ],
169
- };
170
-
171
- const root = render(
172
- <SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
173
- {wrapper}
174
- );
175
-
176
- const audits = root.getAllByText(/^(Audit|Metric) [0-9]$/);
177
-
178
- expect(root.getByText('Highest impact')).toBeTruthy();
179
- expect(audits.map(a => a.textContent)).toEqual([
180
- 'Audit 2',
181
- 'Audit 1',
182
- ]);
183
- });
184
-
185
- it('hides highest impact if nothing to show', async () => {
186
- const category: any = {
187
- id: 'performance',
188
- score: 1,
189
- auditRefs: [
190
- /* eslint-disable max-len */
191
- {result: {score: 1, scoreDisplayMode: 'binary', title: 'Audit 1'}, weight: 1, group: 'diagnostics'},
192
- {result: {score: 0, scoreDisplayMode: 'binary', title: 'Audit 2'}, weight: 1, group: 'hidden'},
193
- {result: {score: null, scoreDisplayMode: 'informative', title: 'Audit 3'}, weight: 1, group: 'diagnostics'},
194
- /* eslint-enable max-len */
195
- ],
196
- };
197
-
198
- const root = render(
199
- <SummaryTooltip category={category} gatherMode="navigation" url="https://example.com"/>,
200
- {wrapper}
201
- );
202
-
203
- expect(() => root.getByText('Highest impact')).toThrow();
204
- expect(() => root.getByText(/^Audit [0-9]$/)).toThrow();
205
- });
206
- });
@@ -1,7 +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
- export {};
7
- //# sourceMappingURL=summary-test.d.ts.map