lighthouse 10.0.0-dev.20230213 → 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 (75) hide show
  1. package/core/audits/dobetterweb/doctype.d.ts +3 -2
  2. package/core/audits/dobetterweb/doctype.js +15 -4
  3. package/core/audits/dobetterweb/paste-preventing-inputs.js +2 -2
  4. package/core/gather/driver/network-monitor.js +1 -3
  5. package/core/gather/gatherers/bf-cache-failures.js +7 -8
  6. package/package.json +1 -1
  7. package/shared/localization/locales/en-US.json +1 -1
  8. package/shared/localization/locales/en-XL.json +1 -1
  9. package/.codecov.yml +0 -22
  10. package/.cz-config.js +0 -24
  11. package/.gitattributes +0 -5
  12. package/.mailmap +0 -6
  13. package/CODE_OF_CONDUCT.md +0 -93
  14. package/eslint-local-rules.cjs +0 -106
  15. package/flow-report/test/app-test.d.ts +0 -7
  16. package/flow-report/test/app-test.tsx +0 -52
  17. package/flow-report/test/common-test.d.ts +0 -7
  18. package/flow-report/test/common-test.tsx +0 -103
  19. package/flow-report/test/flow-report-pptr-test.d.ts +0 -7
  20. package/flow-report/test/flow-report-pptr-test.ts +0 -59
  21. package/flow-report/test/header-test.d.ts +0 -7
  22. package/flow-report/test/header-test.tsx +0 -55
  23. package/flow-report/test/run-flow-report-tests.sh +0 -20
  24. package/flow-report/test/sample-flow.d.ts +0 -7
  25. package/flow-report/test/sample-flow.ts +0 -17
  26. package/flow-report/test/setup/env-setup.d.ts +0 -11
  27. package/flow-report/test/setup/env-setup.ts +0 -55
  28. package/flow-report/test/sidebar/flow-test.d.ts +0 -7
  29. package/flow-report/test/sidebar/flow-test.tsx +0 -65
  30. package/flow-report/test/sidebar/sidebar-test.d.ts +0 -7
  31. package/flow-report/test/sidebar/sidebar-test.tsx +0 -116
  32. package/flow-report/test/summary/category-test.d.ts +0 -7
  33. package/flow-report/test/summary/category-test.tsx +0 -206
  34. package/flow-report/test/summary/summary-test.d.ts +0 -7
  35. package/flow-report/test/summary/summary-test.tsx +0 -124
  36. package/flow-report/test/topbar-test.d.ts +0 -7
  37. package/flow-report/test/topbar-test.tsx +0 -84
  38. package/flow-report/test/util-test.d.ts +0 -7
  39. package/flow-report/test/util-test.tsx +0 -133
  40. package/flow-report/test/wrappers/category-score-test.d.ts +0 -7
  41. package/flow-report/test/wrappers/category-score-test.tsx +0 -84
  42. package/flow-report/test/wrappers/markdown-test.d.ts +0 -7
  43. package/flow-report/test/wrappers/markdown-test.tsx +0 -17
  44. package/report/test/clients/bundle-test.js +0 -65
  45. package/report/test/generator/file-namer-test.js +0 -27
  46. package/report/test/generator/report-generator-test.js +0 -160
  47. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +0 -15
  48. package/report/test/renderer/category-renderer-test.js +0 -575
  49. package/report/test/renderer/components-test.js +0 -124
  50. package/report/test/renderer/crc-details-renderer-test.js +0 -116
  51. package/report/test/renderer/details-renderer-test.js +0 -882
  52. package/report/test/renderer/dom-test.js +0 -257
  53. package/report/test/renderer/element-screenshot-renderer-test.js +0 -183
  54. package/report/test/renderer/i18n-formatter-test.js +0 -179
  55. package/report/test/renderer/performance-category-renderer-test.js +0 -417
  56. package/report/test/renderer/pwa-category-renderer-test.js +0 -301
  57. package/report/test/renderer/report-renderer-axe-test.js +0 -85
  58. package/report/test/renderer/report-renderer-test.js +0 -268
  59. package/report/test/renderer/report-ui-features-test.js +0 -773
  60. package/report/test/renderer/report-utils-test.js +0 -219
  61. package/report/test/renderer/snippet-renderer-test.js +0 -291
  62. package/report/test/renderer/text-encoding-test.js +0 -43
  63. package/report/test-assets/faux-psi-template.html +0 -177
  64. package/report/test-assets/faux-psi.d.ts +0 -34
  65. package/report/test-assets/faux-psi.js +0 -168
  66. package/report/test-assets/lhr-3.0.0.json +0 -2332
  67. package/report/test-assets/lhr-4.3.0.json +0 -4754
  68. package/report/test-assets/lhr-5.0.0.json +0 -5994
  69. package/report/test-assets/lhr-6.0.0.json +0 -7222
  70. package/report/test-assets/lhr-8.5.0.json +0 -8679
  71. package/shared/test/localization/format-test.js +0 -430
  72. package/shared/test/localization/locales-test.js +0 -45
  73. package/shared/test/localization/swap-locale-test.js +0 -127
  74. package/shared/test/util-test.js +0 -214
  75. package/vercel.json +0 -6
@@ -1,124 +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 {SummaryHeader, SummaryFlowStep} from '../../src/summary/summary';
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('SummaryHeader', () => {
28
- it('renders header content', async () => {
29
- const root = render(<SummaryHeader/>, {wrapper});
30
-
31
- const lhrCounts = root.getByText(/·/);
32
- expect(root.getByText('Summary')).toBeTruthy();
33
- expect(lhrCounts.textContent).toEqual(
34
- '2 navigation reports · 1 timespan report · 1 snapshot report'
35
- );
36
- });
37
- });
38
-
39
- describe('SummaryFlowStep', () => {
40
- it('renders navigation step', async () => {
41
- const root = render(<SummaryFlowStep
42
- lhr={flowResult.steps[0].lhr}
43
- label="Navigation (1)"
44
- hashIndex={0}
45
- />, {wrapper});
46
-
47
- expect(root.getByTestId('SummaryNavigationHeader')).toBeTruthy();
48
-
49
- expect(root.getByText('Navigation (1)')).toBeTruthy();
50
-
51
- const screenshot =
52
- root.getByAltText('Screenshot of a page tested by Lighthouse') as HTMLImageElement;
53
- expect(screenshot.src).toMatch(/data:image\/jpeg;base64/);
54
-
55
- const gauges = root.getAllByTestId('CategoryScore');
56
- expect(gauges).toHaveLength(4);
57
-
58
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
59
- expect(links.map(a => a.href)).toEqual([
60
- 'https://www.mikescerealshack.co/',
61
- 'file:///Users/example/report.html/#index=0',
62
- 'file:///Users/example/report.html/#index=0&anchor=performance',
63
- 'file:///Users/example/report.html/#index=0&anchor=accessibility',
64
- 'file:///Users/example/report.html/#index=0&anchor=best-practices',
65
- 'file:///Users/example/report.html/#index=0&anchor=seo',
66
- ]);
67
- });
68
-
69
- it('renders timespan step', async () => {
70
- const root = render(<SummaryFlowStep
71
- lhr={flowResult.steps[1].lhr}
72
- label="Timespan (1)"
73
- hashIndex={1}
74
- />, {wrapper});
75
-
76
- expect(() => root.getByTestId('SummaryNavigationHeader')).toThrow();
77
-
78
- expect(root.getByText('Timespan (1)')).toBeTruthy();
79
-
80
- expect(() => root.getByAltText('Screenshot of a page tested by Lighthouse')).toThrow();
81
-
82
- // Accessibility and SEO are missing in timespan.
83
- const nullCategories = root.getAllByTestId('SummaryCategory__null');
84
- expect(nullCategories).toHaveLength(2);
85
-
86
- const gauges = root.getAllByTestId('CategoryScore');
87
- expect(gauges).toHaveLength(2);
88
-
89
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
90
- expect(links.map(a => a.href)).toEqual([
91
- 'file:///Users/example/report.html/#index=1',
92
- 'file:///Users/example/report.html/#index=1&anchor=performance',
93
- 'file:///Users/example/report.html/#index=1&anchor=best-practices',
94
- ]);
95
- });
96
-
97
- it('renders snapshot step', async () => {
98
- const root = render(<SummaryFlowStep
99
- lhr={flowResult.steps[2].lhr}
100
- label="Snapshot (1)"
101
- hashIndex={2}
102
- />, {wrapper});
103
-
104
- expect(() => root.getByTestId('SummaryNavigationHeader')).toThrow();
105
-
106
- expect(root.getByText('Snapshot (1)')).toBeTruthy();
107
-
108
- const screenshot =
109
- root.getByAltText('Screenshot of a page tested by Lighthouse') as HTMLImageElement;
110
- expect(screenshot.src).toMatch(/data:image\/webp;base64/);
111
-
112
- const gauges = root.getAllByTestId('CategoryScore');
113
- expect(gauges).toHaveLength(4);
114
-
115
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
116
- expect(links.map(a => a.href)).toEqual([
117
- 'file:///Users/example/report.html/#index=2',
118
- 'file:///Users/example/report.html/#index=2&anchor=performance',
119
- 'file:///Users/example/report.html/#index=2&anchor=accessibility',
120
- 'file:///Users/example/report.html/#index=2&anchor=best-practices',
121
- 'file:///Users/example/report.html/#index=2&anchor=seo',
122
- ]);
123
- });
124
- });
@@ -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=topbar-test.d.ts.map
@@ -1,84 +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 jestMock from 'jest-mock';
8
- import {FunctionComponent} from 'preact';
9
- import {act, render} from '@testing-library/preact';
10
-
11
- import {FlowResultContext, OptionsContext} from '../src/util';
12
- import {I18nProvider} from '../src/i18n/i18n';
13
- import {Topbar, saveHtml} from '../src/topbar';
14
-
15
- const mockSaveFile = jestMock.fn();
16
- const defaultSaveFile = saveHtml.saveFile;
17
-
18
- const flowResult = {
19
- name: 'User flow',
20
- steps: [{lhr: {
21
- fetchTime: '2021-09-14T22:24:22.462Z',
22
- configSettings: {locale: 'en-US'},
23
- i18n: {rendererFormattedStrings: {}},
24
- }}],
25
- } as any;
26
-
27
- let wrapper: FunctionComponent;
28
- let options: LH.FlowReportOptions;
29
-
30
- before(() => {
31
- mockSaveFile.mockReset();
32
- options = {};
33
- wrapper = ({children}) => (
34
- <OptionsContext.Provider value={options}>
35
- <FlowResultContext.Provider value={flowResult}>
36
- <I18nProvider>
37
- {children}
38
- </I18nProvider>
39
- </FlowResultContext.Provider>
40
- </OptionsContext.Provider>
41
- );
42
- });
43
-
44
- after(() => {
45
- saveHtml.saveFile = defaultSaveFile;
46
- });
47
-
48
- it('save button opens save dialog for HTML file', async () => {
49
- saveHtml.saveFile = mockSaveFile;
50
- options = {getReportHtml: () => '<html></html>'};
51
- const root = render(<Topbar onMenuClick={() => {}}/>, {wrapper});
52
-
53
- const saveButton = root.getByText('Save');
54
- saveButton.click();
55
-
56
- expect(mockSaveFile).toHaveBeenCalledWith(
57
- expect.any(Blob),
58
- 'User-flow_2021-09-14_22-24-22.html'
59
- );
60
- });
61
-
62
- it('provides save as gist option if defined', async () => {
63
- const saveAsGist = jestMock.fn();
64
- options = {saveAsGist};
65
- const root = render(<Topbar onMenuClick={() => {}}/>, {wrapper});
66
-
67
- const saveButton = root.getByText('Save as Gist');
68
- saveButton.click();
69
-
70
- expect(saveAsGist).toHaveBeenCalledWith(flowResult);
71
- });
72
-
73
- it('toggles help dialog', async () => {
74
- const root = render(<Topbar onMenuClick={() => {}}/>, {wrapper});
75
-
76
- expect(root.queryByText(/Use Navigation reports to/)).toBeFalsy();
77
- const helpButton = root.getByText('Understanding Flows');
78
-
79
- await act(() => helpButton.click());
80
- expect(root.getByText(/Use Navigation reports to/)).toBeTruthy();
81
-
82
- await act(() => helpButton.click());
83
- expect(root.queryByText(/Use Navigation reports to/)).toBeFalsy();
84
- });
@@ -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=util-test.d.ts.map
@@ -1,133 +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 jestMock from 'jest-mock';
8
- import {render} from '@testing-library/preact';
9
- import {renderHook} from '@testing-library/preact-hooks/src/index';
10
- import {FunctionComponent} from 'preact';
11
- import {act} from 'preact/test-utils';
12
-
13
- import {FlowResultContext, useExternalRenderer, useHashState} from '../src/util';
14
- import {flowResult} from './sample-flow';
15
-
16
- let wrapper: FunctionComponent;
17
-
18
- beforeEach(() => {
19
- global.console.warn = jestMock.fn();
20
- wrapper = ({children}) => (
21
- <FlowResultContext.Provider value={flowResult}>{children}</FlowResultContext.Provider>
22
- );
23
- });
24
-
25
- describe('useHashState', () => {
26
- it('gets current lhr index from url hash', () => {
27
- global.location.hash = '#index=1';
28
- const {result} = renderHook(() => useHashState(), {wrapper});
29
- expect(console.warn).not.toHaveBeenCalled();
30
- expect(result.current).toEqual({
31
- index: 1,
32
- currentLhr: flowResult.steps[1].lhr,
33
- anchor: null,
34
- });
35
- });
36
-
37
- it('gets anchor id from url hash', () => {
38
- global.location.hash = '#index=1&anchor=seo';
39
- const {result} = renderHook(() => useHashState(), {wrapper});
40
- expect(console.warn).not.toHaveBeenCalled();
41
- expect(result.current).toEqual({
42
- index: 1,
43
- currentLhr: flowResult.steps[1].lhr,
44
- anchor: 'seo',
45
- });
46
- });
47
-
48
- it('changes on navigation', async () => {
49
- global.location.hash = '#index=1';
50
- const render = renderHook(() => useHashState(), {wrapper});
51
-
52
- expect(render.result.current).toEqual({
53
- index: 1,
54
- currentLhr: flowResult.steps[1].lhr,
55
- anchor: null,
56
- });
57
-
58
- await act(() => {
59
- global.location.hash = '#index=2&anchor=seo';
60
- });
61
- await render.waitForNextUpdate();
62
-
63
- expect(console.warn).not.toHaveBeenCalled();
64
- expect(render.result.current).toEqual({
65
- index: 2,
66
- currentLhr: flowResult.steps[2].lhr,
67
- anchor: 'seo',
68
- });
69
- });
70
-
71
- it('return null if lhr index is unset', () => {
72
- const {result} = renderHook(() => useHashState(), {wrapper});
73
- expect(console.warn).not.toHaveBeenCalled();
74
- expect(result.current).toBeNull();
75
- });
76
-
77
- it('return null if lhr index is out of bounds', () => {
78
- global.location.hash = '#index=5';
79
- const {result} = renderHook(() => useHashState(), {wrapper});
80
- expect(console.warn).toHaveBeenCalled();
81
- expect(result.current).toBeNull();
82
- });
83
-
84
- it('returns null for invalid value', () => {
85
- global.location.hash = '#index=OHNO';
86
- const {result} = renderHook(() => useHashState(), {wrapper});
87
- expect(console.warn).toHaveBeenCalled();
88
- expect(result.current).toBeNull();
89
- });
90
-
91
- it('returns null for invalid value with valid anchor', () => {
92
- global.location.hash = '#index=OHNO&anchor=seo';
93
- const {result} = renderHook(() => useHashState(), {wrapper});
94
- expect(console.warn).toHaveBeenCalled();
95
- expect(result.current).toBeNull();
96
- });
97
- });
98
-
99
- describe('useExternalRenderer', () => {
100
- it('attaches DOM subtree of render callback', () => {
101
- const Container: FunctionComponent = () => {
102
- const ref = useExternalRenderer<HTMLDivElement>(() => {
103
- const el = document.createElement('div');
104
- el.textContent = 'Some text';
105
- return el;
106
- });
107
- return <div ref={ref}/>;
108
- };
109
-
110
- const root = render(<Container/>);
111
-
112
- expect(root.getByText('Some text')).toBeTruthy();
113
- });
114
-
115
- it('re-renders DOM subtree when input changes', () => {
116
- const Container: FunctionComponent<{text: string}> = ({text}) => {
117
- const ref = useExternalRenderer<HTMLDivElement>(() => {
118
- const el = document.createElement('div');
119
- el.textContent = text;
120
- return el;
121
- }, [text]);
122
- return <div ref={ref}/>;
123
- };
124
-
125
- const root = render(<Container text="Some text"/>);
126
-
127
- expect(root.getByText('Some text')).toBeTruthy();
128
-
129
- root.rerender(<Container text="New text"/>);
130
-
131
- expect(root.getByText('New text')).toBeTruthy();
132
- });
133
- });
@@ -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-score-test.d.ts.map
@@ -1,84 +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 {I18nProvider} from '../../src/i18n/i18n';
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('CategoryScore', () => {
28
- it('renders score gauge', () => {
29
- const category: any = {
30
- id: 'seo',
31
- score: 0.95,
32
- auditRefs: [],
33
- };
34
- const root = render(
35
- <CategoryScore category={category} href="#seo" gatherMode="navigation"/>,
36
- {wrapper}
37
- );
38
-
39
- const link = root.getByRole('link') as HTMLAnchorElement;
40
-
41
- expect(link.href).toEqual('file:///Users/example/report.html/#seo');
42
- expect(root.getByText('95')).toBeTruthy();
43
- expect(root.baseElement.querySelector('.lh-gauge__label')).toBeFalsy();
44
- });
45
-
46
- it('renders error gauge', () => {
47
- const category: any = {
48
- id: 'seo',
49
- score: null,
50
- auditRefs: [],
51
- };
52
- const root = render(
53
- <CategoryScore category={category} href="#seo" gatherMode="navigation"/>,
54
- {wrapper}
55
- );
56
-
57
- const link = root.getByRole('link') as HTMLAnchorElement;
58
-
59
- expect(link.href).toEqual('file:///Users/example/report.html/#seo');
60
- expect(root.getByText('?')).toBeTruthy();
61
- });
62
-
63
- it('renders category fraction', () => {
64
- const category: any = {
65
- id: 'seo',
66
- auditRefs: [
67
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
68
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}},
69
- {weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}},
70
- {weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}},
71
- ],
72
- };
73
- const root = render(
74
- <CategoryScore category={category} href="#seo" gatherMode="timespan"/>,
75
- {wrapper}
76
- );
77
-
78
- const link = root.getByRole('link') as HTMLAnchorElement;
79
-
80
- expect(link.href).toEqual('file:///Users/example/report.html/#seo');
81
- expect(root.getByText('2/4')).toBeTruthy();
82
- expect(root.baseElement.querySelector('.lh-fraction__label')).toBeFalsy();
83
- });
84
- });
@@ -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=markdown-test.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 {render} from '@testing-library/preact';
8
-
9
- import {Markdown} from '../../src/wrappers/markdown';
10
-
11
- describe('Markdown', () => {
12
- it('renders markdown text', () => {
13
- const root = render(<Markdown text="Some `fancy` text"/>);
14
- const text = root.getByText(/^Some.*text$/);
15
- expect(text.innerHTML).toEqual('Some <code>fancy</code> text');
16
- });
17
- });
@@ -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 fs from 'fs';
8
-
9
- import jsdom from 'jsdom';
10
- import jestMock from 'jest-mock';
11
-
12
- import * as lighthouseRenderer from '../../clients/bundle.js';
13
- import {LH_ROOT} from '../../../root.js';
14
-
15
- const sampleResultsStr =
16
- fs.readFileSync(LH_ROOT + '/core/test/results/sample_v2.json', 'utf-8');
17
-
18
- describe('lighthouseRenderer bundle', () => {
19
- let document;
20
- before(() => {
21
- global.console.warn = jestMock.fn();
22
-
23
- const {window} = new jsdom.JSDOM();
24
- document = window.document;
25
-
26
- global.window = global.self = window;
27
- global.window.requestAnimationFrame = fn => fn();
28
- global.HTMLInputElement = window.HTMLInputElement;
29
- // Stub out matchMedia for Node.
30
- global.self.matchMedia = function() {
31
- return {
32
- addListener: function() {},
33
- };
34
- };
35
- global.window.ResizeObserver = class ResizeObserver {
36
- observe() { }
37
- unobserve() { }
38
- };
39
- });
40
-
41
- after(() => {
42
- global.window = global.self = undefined;
43
- global.HTMLInputElement = undefined;
44
- });
45
-
46
- it('renders an LHR to DOM', () => {
47
- const lhr = /** @type {LH.Result} */ JSON.parse(sampleResultsStr);
48
- const reportContainer = document.body;
49
- reportContainer.classList.add('lh-vars', 'lh-root');
50
-
51
- const dom = new lighthouseRenderer.DOM(reportContainer.ownerDocument);
52
- const renderer = new lighthouseRenderer.ReportRenderer(dom);
53
- renderer.renderReport(lhr, reportContainer);
54
- const features = new lighthouseRenderer.ReportUIFeatures(renderer._dom);
55
- features.initFeatures(lhr);
56
-
57
- // Check that the report exists and has some content.
58
- expect(reportContainer instanceof document.defaultView.Element).toBeTruthy();
59
- expect(reportContainer.outerHTML.length).toBeGreaterThan(50000);
60
-
61
- const title = reportContainer.querySelector('.lh-audit-group--metrics')
62
- .querySelector('.lh-audit-group__title');
63
- expect(title.textContent).toEqual('Metrics');
64
- });
65
- });
@@ -1,27 +0,0 @@
1
- /**
2
- * @license Copyright 2017 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
- 'use strict';
7
-
8
- import assert from 'assert/strict';
9
-
10
- import {getLhrFilenamePrefix} from '../../generator/file-namer.js';
11
-
12
- describe('file-namer helper', () => {
13
- it('generates filename prefixes', () => {
14
- const results = {
15
- finalDisplayedUrl: 'https://testexample.com',
16
- fetchTime: '2017-01-06T02:34:56.217Z',
17
- };
18
- const str = getLhrFilenamePrefix(results);
19
- // we want the filename to match user timezone, however these tests will run on multiple TZs
20
- assert.ok(str.startsWith('testexample.com'), 'hostname is missing');
21
- assert.ok(str.includes('2017-'), 'full year is missing');
22
- assert.ok(str.endsWith('-56'), 'seconds value is not at the end');
23
- // regex of hostname_YYYY-MM-DD_HH-MM-SS
24
- const regex = /testexample\.com_\d{4}-[0-1][[0-9]-[0-1][[0-9]_[0-2][0-9]-[0-5][0-9]-[0-5][0-9]/;
25
- assert.ok(regex.test(str), `${str} doesn't match pattern: hostname_YYYY-MM-DD_HH-MM-SS`);
26
- });
27
- });