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,219 +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
-
7
- import assert from 'assert/strict';
8
-
9
- import {ReportUtils} from '../../renderer/report-utils.js';
10
- import {I18nFormatter} from '../../renderer/i18n-formatter.js';
11
- import {readJson} from '../../../core/test/test-utils.js';
12
- import {Globals} from '../../renderer/report-globals.js';
13
-
14
- const sampleResult = readJson('../../../core/test/results/sample_v2.json', import.meta);
15
-
16
- describe('util helpers', () => {
17
- beforeEach(() => {
18
- Globals.apply({
19
- providedStrings: {},
20
- i18n: new I18nFormatter('en'),
21
- reportJson: null,
22
- });
23
- });
24
-
25
- afterEach(() => {
26
- Globals.i18n = undefined;
27
- });
28
-
29
- it('calculates a score ratings', () => {
30
- assert.equal(ReportUtils.calculateRating(0.0), 'fail');
31
- assert.equal(ReportUtils.calculateRating(0.10), 'fail');
32
- assert.equal(ReportUtils.calculateRating(0.45), 'fail');
33
- assert.equal(ReportUtils.calculateRating(0.5), 'average');
34
- assert.equal(ReportUtils.calculateRating(0.75), 'average');
35
- assert.equal(ReportUtils.calculateRating(0.80), 'average');
36
- assert.equal(ReportUtils.calculateRating(0.90), 'pass');
37
- assert.equal(ReportUtils.calculateRating(1.00), 'pass');
38
- });
39
-
40
- it('builds device emulation string', () => {
41
- const get = settings => ReportUtils.getEmulationDescriptions(settings).deviceEmulation;
42
- /* eslint-disable max-len */
43
- assert.equal(get({formFactor: 'mobile', screenEmulation: {disabled: false, mobile: true}}), 'Emulated Moto G Power');
44
- assert.equal(get({formFactor: 'mobile', screenEmulation: {disabled: true, mobile: true}}), 'No emulation');
45
- assert.equal(get({formFactor: 'mobile', screenEmulation: {disabled: true, mobile: true}, channel: 'devtools'}), 'Emulated Moto G Power');
46
- assert.equal(get({formFactor: 'desktop', screenEmulation: {disabled: false, mobile: false}}), 'Emulated Desktop');
47
- assert.equal(get({formFactor: 'desktop', screenEmulation: {disabled: true, mobile: false}}), 'No emulation');
48
- assert.equal(get({formFactor: 'desktop', screenEmulation: {disabled: true, mobile: true}, channel: 'devtools'}), 'Emulated Desktop');
49
- /* eslint-enable max-len */
50
- });
51
-
52
- it('builds throttling strings when provided', () => {
53
- const descriptions = ReportUtils.getEmulationDescriptions({
54
- throttlingMethod: 'provided',
55
- screenEmulation: {disabled: true},
56
- });
57
- assert.equal(descriptions.cpuThrottling, 'Provided by environment');
58
- assert.equal(descriptions.networkThrottling, 'Provided by environment');
59
- assert.equal(descriptions.screenEmulation, undefined);
60
- });
61
-
62
- it('builds throttling strings when devtools', () => {
63
- const descriptions = ReportUtils.getEmulationDescriptions({
64
- throttlingMethod: 'devtools',
65
- throttling: {
66
- cpuSlowdownMultiplier: 4.5,
67
- requestLatencyMs: 565,
68
- downloadThroughputKbps: 1400.00000000001,
69
- uploadThroughputKbps: 600,
70
- },
71
- screenEmulation: {disabled: true},
72
- });
73
-
74
- // eslint-disable-next-line max-len
75
- assert.equal(descriptions.networkThrottling, '565\xa0ms HTTP RTT, 1,400\xa0kb/s down, 600\xa0kb/s up (DevTools)');
76
- assert.equal(descriptions.cpuThrottling, '4.5x slowdown (DevTools)');
77
- });
78
-
79
- it('builds throttling strings when simulate', () => {
80
- const descriptions = ReportUtils.getEmulationDescriptions({
81
- throttlingMethod: 'simulate',
82
- throttling: {
83
- cpuSlowdownMultiplier: 2,
84
- rttMs: 150,
85
- throughputKbps: 1600,
86
- },
87
- screenEmulation: {width: 100, height: 100, deviceScaleFactor: 2},
88
- });
89
-
90
- // eslint-disable-next-line max-len
91
- assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\xa0kb/s throughput (Simulated)');
92
- assert.equal(descriptions.cpuThrottling, '2x slowdown (Simulated)');
93
- assert.equal(descriptions.screenEmulation, '100x100, DPR 2');
94
- });
95
-
96
- describe('#prepareReportResult', () => {
97
- it('appends stack pack descriptions to auditRefs', () => {
98
- const clonedSampleResult = JSON.parse(JSON.stringify(sampleResult));
99
- const iconDataURL = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg"%3E%3C/svg%3E';
100
- clonedSampleResult.stackPacks = [{
101
- id: 'snackpack',
102
- title: 'SnackPack',
103
- iconDataURL,
104
- descriptions: {
105
- 'unused-css-rules': 'Consider using snacks in packs.',
106
- },
107
- }];
108
- const preparedResult = ReportUtils.prepareReportResult(clonedSampleResult);
109
-
110
- const perfAuditRefs = preparedResult.categories.performance.auditRefs;
111
- const unusedCssRef = perfAuditRefs.find(ref => ref.id === 'unused-css-rules');
112
- assert.deepStrictEqual(unusedCssRef.stackPacks, [{
113
- title: 'SnackPack',
114
- iconDataURL,
115
- description: 'Consider using snacks in packs.',
116
- }]);
117
-
118
- // No stack pack on audit wth no stack pack.
119
- const interactiveRef = perfAuditRefs.find(ref => ref.id === 'interactive');
120
- assert.strictEqual(interactiveRef.stackPacks, undefined);
121
- });
122
-
123
- it('identifies entities on items of tables with urls', () => {
124
- const clonedSampleResult = JSON.parse(JSON.stringify(sampleResult));
125
-
126
- const auditsWithTableDetails = Object.values(clonedSampleResult.audits)
127
- .filter(audit => audit.details?.type === 'table');
128
- assert.notEqual(auditsWithTableDetails.length, 0);
129
-
130
- // collect audit names that might have urls
131
- const auditsThatDontHaveUrls = ['bf-cache', 'font-size']; // no urls in data-set
132
- const auditsWithUrls = auditsWithTableDetails.filter(audit => {
133
- if (auditsThatDontHaveUrls.includes(audit.id)) return false;
134
- const urlFields = ['url', 'source-location'];
135
- return audit.details.headings.some(heading =>
136
- urlFields.includes(heading.valueType) ||
137
- urlFields.includes(heading.subItemsHeading?.valueType)
138
- );
139
- }).map(audit => audit.id);
140
- assert.notEqual(auditsWithUrls.length, 0);
141
-
142
- const preparedResult = ReportUtils.prepareReportResult(clonedSampleResult);
143
-
144
- // ensure each audit that had urls detected to have marked entities.
145
- for (const id of auditsWithUrls) {
146
- const foundEntities = preparedResult.audits[id].details.items.some(item => item.entity);
147
- assert.equal(foundEntities, true);
148
- }
149
- });
150
- });
151
-
152
- describe('#shouldDisplayAsFraction', () => {
153
- it('returns true for timespan and snapshot', () => {
154
- expect(ReportUtils.shouldDisplayAsFraction('navigation')).toEqual(false);
155
- expect(ReportUtils.shouldDisplayAsFraction('timespan')).toEqual(true);
156
- expect(ReportUtils.shouldDisplayAsFraction('snapshot')).toEqual(true);
157
- expect(ReportUtils.shouldDisplayAsFraction(undefined)).toEqual(false);
158
- });
159
- });
160
-
161
- describe('#calculateCategoryFraction', () => {
162
- it('returns passed audits and total audits', () => {
163
- const category = {
164
- id: 'performance',
165
- auditRefs: [
166
- {weight: 3, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
167
- {weight: 2, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
168
- {weight: 0, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
169
- {weight: 1, result: {score: 0, scoreDisplayMode: 'binary'}, group: 'metrics'},
170
- ],
171
- };
172
- const fraction = ReportUtils.calculateCategoryFraction(category);
173
- expect(fraction).toEqual({
174
- numPassableAudits: 4,
175
- numPassed: 3,
176
- numInformative: 0,
177
- totalWeight: 6,
178
- });
179
- });
180
-
181
- it('ignores manual audits, N/A audits, and hidden audits', () => {
182
- const category = {
183
- id: 'performance',
184
- auditRefs: [
185
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
186
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'hidden'},
187
- {weight: 1, result: {score: 0, scoreDisplayMode: 'manual'}, group: 'metrics'},
188
- {weight: 1, result: {score: 0, scoreDisplayMode: 'notApplicable'}, group: 'metrics'},
189
- ],
190
- };
191
- const fraction = ReportUtils.calculateCategoryFraction(category);
192
- expect(fraction).toEqual({
193
- numPassableAudits: 1,
194
- numPassed: 1,
195
- numInformative: 0,
196
- totalWeight: 1,
197
- });
198
- });
199
-
200
- it('tracks informative audits separately', () => {
201
- const category = {
202
- id: 'performance',
203
- auditRefs: [
204
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
205
- {weight: 1, result: {score: 1, scoreDisplayMode: 'binary'}, group: 'metrics'},
206
- {weight: 0, result: {score: 1, scoreDisplayMode: 'informative'}, group: 'metrics'},
207
- {weight: 1, result: {score: 0, scoreDisplayMode: 'informative'}, group: 'metrics'},
208
- ],
209
- };
210
- const fraction = ReportUtils.calculateCategoryFraction(category);
211
- expect(fraction).toEqual({
212
- numPassableAudits: 2,
213
- numPassed: 2,
214
- numInformative: 2,
215
- totalWeight: 2,
216
- });
217
- });
218
- });
219
- });
@@ -1,291 +0,0 @@
1
- /**
2
- * @license Copyright 2019 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 assert from 'assert/strict';
8
-
9
- import jsdom from 'jsdom';
10
-
11
- import {I18nFormatter} from '../../renderer/i18n-formatter.js';
12
- import {DOM} from '../../renderer/dom.js';
13
- import {SnippetRenderer} from '../../renderer/snippet-renderer.js';
14
- import {Globals} from '../../renderer/report-globals.js';
15
-
16
- /* Generates a snippet lines array like this (for a single range from 1 to 4):
17
- [
18
- {number: 1, content 'L1'},
19
- {number: 2, content 'L2'},
20
- {number: 3, content 'L3'},
21
- {number: 4, content 'L4'}
22
- ];
23
- */
24
- function generateAvailableLinesArray(availableLineRanges) {
25
- const lines = [];
26
- availableLineRanges.forEach(({from, to}) => {
27
- for (let i = from; i <= to; i++) {
28
- lines.push({
29
- lineNumber: i,
30
- content: 'L' + i,
31
- });
32
- }
33
- });
34
- return lines;
35
- }
36
-
37
- function makeSnippetDetails({
38
- lineMessages,
39
- generalMessages,
40
- lines = null,
41
- title = 'Snippet',
42
- lineCount,
43
- }) {
44
- return {
45
- type: 'snippet',
46
- title: title,
47
- lines: lines,
48
- lineMessages,
49
- generalMessages,
50
- lineCount,
51
- };
52
- }
53
-
54
- describe('DetailsRenderer', () => {
55
- let dom;
56
-
57
- before(() => {
58
- Globals.apply({
59
- providedStrings: {},
60
- i18n: new I18nFormatter('en'),
61
- reportJson: null,
62
- });
63
- const {document} = new jsdom.JSDOM().window;
64
- dom = new DOM(document);
65
- });
66
-
67
- after(() => {
68
- Globals.i18n = undefined;
69
- });
70
-
71
- function renderSnippet(details) {
72
- const el = SnippetRenderer.render(dom, details, {});
73
-
74
- return {
75
- el,
76
- contentLines: el.querySelectorAll('.lh-snippet__line--content'),
77
- highlightedContentLines: el.querySelectorAll('.lh-snippet__line--content-highlighted'),
78
- collapsedContentLines: el.querySelectorAll(
79
- '.lh-snippet__line--content.lh-snippet__show-if-expanded'
80
- ),
81
- uncollapsedContentLines: el.querySelectorAll(
82
- '.lh-snippet__line--content:not(.lh-snippet__show-if-expanded)'
83
- ),
84
- messageLines: el.querySelectorAll('.lh-snippet__line--message'),
85
- omittedLinesIndicatorsWhenExpanded: el.querySelectorAll(
86
- '.lh-snippet__line--placeholder:not(.lh-snippet__show-if-collapsed)'
87
- ),
88
- omittedLinesIndicatorsWhenCollapsed: el.querySelectorAll(
89
- '.lh-snippet__line--placeholder:not(.lh-snippet__show-if-expanded)'
90
- ),
91
- title: el.querySelector('.lh-snippet__title'),
92
- toggleExpandButton: el.querySelector('.lh-snippet__toggle-expand'),
93
- };
94
- }
95
-
96
- it('Renders snippet with a message at the very top', () => {
97
- const details = makeSnippetDetails({
98
- lineMessages: [
99
- {
100
- lineNumber: 1,
101
- message: 'Error',
102
- },
103
- ],
104
- generalMessages: [],
105
- lines: generateAvailableLinesArray([{from: 1, to: 6}]),
106
- lineCount: 100,
107
- });
108
- const {contentLines, messageLines, collapsedContentLines} = renderSnippet(details);
109
-
110
- // 5 lines are visible, 1 is collapsed
111
- assert.equal(collapsedContentLines.length, 1);
112
- // All available lines are shown on expansion
113
- assert.equal(contentLines.length, 6);
114
- // 100 lines in total, so lines towards the end won't be shown
115
- const lastLine = contentLines[contentLines.length - 1];
116
- assert.equal(lastLine.nextSibling.textContent.trim(), '…');
117
-
118
- // Shows message for second line
119
- assert.equal(messageLines[0].textContent.trim(), 'Error');
120
- assert.equal(messageLines[0].previousSibling.textContent.replace(/\s/g, ''), '1L1');
121
- });
122
-
123
- it('Renders first few lines if there are no messages', () => {
124
- const details = makeSnippetDetails({
125
- lineMessages: [],
126
- generalMessages: [],
127
- lines: generateAvailableLinesArray([{from: 1, to: 6}]),
128
- lineCount: 100,
129
- });
130
- const {
131
- uncollapsedContentLines,
132
- omittedLinesIndicatorsWhenExpanded,
133
- omittedLinesIndicatorsWhenCollapsed,
134
- highlightedContentLines,
135
- } = renderSnippet(details);
136
- const lastUncollapsedLine = uncollapsedContentLines[uncollapsedContentLines.length - 1];
137
-
138
- // Shows first 5 visible lines
139
- assert.equal(lastUncollapsedLine.textContent.replace(/\s/g, ''), '5L5');
140
- // "..." after the available lines, but only shows in expanded state
141
- assert.equal(omittedLinesIndicatorsWhenExpanded.length, 1);
142
- assert.equal(omittedLinesIndicatorsWhenCollapsed.length, 0);
143
- // nothing is highlighted
144
- assert.equal(highlightedContentLines.length, 0);
145
- });
146
-
147
- it('Renders first few lines if there are no messages for specific lines', () => {
148
- const details = makeSnippetDetails({
149
- lineMessages: [],
150
- generalMessages: [
151
- {
152
- message: 'General error',
153
- },
154
- ],
155
- lines: generateAvailableLinesArray([{from: 1, to: 6}]),
156
- lineCount: 100,
157
- });
158
- const {uncollapsedContentLines, messageLines, highlightedContentLines} = renderSnippet(details);
159
- const lastUncollapsedLine = uncollapsedContentLines[uncollapsedContentLines.length - 1];
160
-
161
- // Shows message
162
- assert.equal(messageLines.length, 1);
163
-
164
- // Shows first 5 visible lines
165
- assert.equal(lastUncollapsedLine.textContent.replace(/\s/g, ''), '5L5');
166
-
167
- // highlight everything (i.e. the 6 lines that are rendered)
168
- assert.equal(highlightedContentLines.length, 6);
169
- });
170
-
171
- it('Renders snippet with multiple messages surrounded by other lines', () => {
172
- const details = makeSnippetDetails({
173
- lineMessages: [
174
- {
175
- lineNumber: 40,
176
- message: 'Error 1',
177
- },
178
- {
179
- lineNumber: 70,
180
- message: 'Error 2',
181
- },
182
- ],
183
- generalMessages: [],
184
- lines: generateAvailableLinesArray([
185
- {
186
- from: 30,
187
- to: 50,
188
- },
189
- {
190
- from: 60,
191
- to: 80,
192
- },
193
- ]),
194
- lineCount: 100,
195
- });
196
- const {
197
- collapsedContentLines,
198
- omittedLinesIndicatorsWhenCollapsed,
199
- omittedLinesIndicatorsWhenExpanded,
200
- highlightedContentLines,
201
- } = renderSnippet(details);
202
-
203
- // first available line is collapsed
204
- assert.equal(collapsedContentLines[0].textContent.replace(/\s/g, ''), '30L30');
205
-
206
- // puts omitted lines placeholder between the two messages
207
- assert.equal(omittedLinesIndicatorsWhenCollapsed.length, 1);
208
- // puts omitted lines placeholder between the two messages and around the whole snippet
209
- assert.equal(omittedLinesIndicatorsWhenExpanded.length, 3);
210
-
211
- // both lines with messages are highlighted
212
- assert.equal(highlightedContentLines.length, 2);
213
- });
214
-
215
- it('Can render both line-specific and non line-specific messages in one snippet', () => {
216
- const details = makeSnippetDetails({
217
- lineMessages: [
218
- {
219
- lineNumber: 5,
220
- message: 'Error on line',
221
- },
222
- ],
223
- generalMessages: [
224
- {
225
- message: 'General error',
226
- },
227
- ],
228
- lines: generateAvailableLinesArray([{from: 1, to: 6}]),
229
- lineCount: 100,
230
- });
231
- const {messageLines} = renderSnippet(details);
232
-
233
- assert.equal(messageLines.length, 2);
234
- });
235
-
236
- it('Renders a snippet header and allows toggling the expanded state', () => {
237
- const details = makeSnippetDetails({
238
- title: 'Test Snippet',
239
- lineMessages: [],
240
- generalMessages: [],
241
- lines: generateAvailableLinesArray([{from: 1, to: 6}]),
242
- lineCount: 100,
243
- });
244
- const {title, toggleExpandButton, el} = renderSnippet(details);
245
-
246
- // Renders title
247
- assert.ok(title.textContent.includes('Test Snippet'));
248
- // Renders toggle button
249
- assert.ok(toggleExpandButton);
250
- assert.ok(!el.classList.contains('lh-snippet--expanded'));
251
-
252
- toggleExpandButton.click();
253
- assert.ok(el.classList.contains('lh-snippet--expanded'));
254
- });
255
-
256
- it('Does not render toggle button if all available lines are already visible', () => {
257
- const details = makeSnippetDetails({
258
- title: 'Test Snippet',
259
- lineMessages: [],
260
- generalMessages: [],
261
- // We show all 5 lines by default, so there's nothing to expand
262
- lines: generateAvailableLinesArray([{from: 1, to: 5}]),
263
- });
264
- const {toggleExpandButton} = renderSnippet(details);
265
-
266
- assert.ok(!toggleExpandButton);
267
- });
268
-
269
- it('Adds ... to lines that have been truncated', () => {
270
- const details = makeSnippetDetails({
271
- lineMessages: [],
272
- generalMessages: [],
273
- lines: [
274
- {
275
- content: 'abc',
276
- lineNumber: 1,
277
- truncated: true,
278
- },
279
- {
280
- content: 'xyz',
281
- lineNumber: 2,
282
- },
283
- ],
284
- lineCount: 2,
285
- });
286
- const {contentLines} = renderSnippet(details);
287
-
288
- assert.ok(contentLines[0].textContent.includes('…'));
289
- assert.ok(!contentLines[1].textContent.includes('…'));
290
- });
291
- });
@@ -1,43 +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 pako from 'pako';
10
-
11
- import {TextEncoding} from '../../renderer/text-encoding.js';
12
- import {LH_ROOT} from '../../../root.js';
13
-
14
- describe('TextEncoding', () => {
15
- before(() => {
16
- global.window = {pako};
17
- });
18
-
19
- after(() => {
20
- global.window = undefined;
21
- });
22
-
23
- /** @type {string} */
24
- async function test(str) {
25
- for (const gzip of [false, true]) {
26
- const binary = await TextEncoding.toBase64(str, {gzip});
27
- const roundtrip = TextEncoding.fromBase64(binary, {gzip});
28
- expect(roundtrip.length).toEqual(str.length);
29
- expect(roundtrip).toEqual(str);
30
- }
31
- }
32
-
33
- it('works', async () => {
34
- await test('');
35
- await test('hello');
36
- await test('😃');
37
- await test('{åß∂œ∑´}');
38
- await test('Some examples of emoji are 😃, 🧘🏻‍♂️, 🌍, 🍞, 🚗, 📞, 🎉, ♥️, 🍆, and 🏁.');
39
- await test('.'.repeat(125183));
40
- await test('😃'.repeat(125183));
41
- await test(fs.readFileSync(LH_ROOT + '/treemap/app/debug.json', 'utf-8'));
42
- });
43
- });
@@ -1,34 +0,0 @@
1
- /**
2
- * @param {any} lhr
3
- * @param {Element} container
4
- */
5
- declare function renderLHReport(lhr: any, container: Element): Promise<void>;
6
- /**
7
- * @param {LH.Locale} locale
8
- */
9
- declare function swapLhrLocale(locale: LH.Locale): Promise<void>;
10
- /**
11
- * Tweak the LHR to make the desktop and mobile reports easier to identify.
12
- * Adjusted: Perf category name and score, and emoji placed on top of key screenshots.
13
- * @param {LH.Result} lhr
14
- * @param {string} tabId
15
- */
16
- declare function distinguishLHR(lhr: LH.Result, tabId: string): Promise<void>;
17
- /**
18
- * Add 📱 and 💻 emoji on top of screenshot
19
- * @param {string} datauri
20
- * @param {string} tabId
21
- */
22
- declare function decorateScreenshot(datauri: string, tabId: string): Promise<string>;
23
- type lighthouseRenderer = typeof import("../clients/bundle.js");
24
- /**
25
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
26
- * 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
27
- * 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.
28
- */
29
- /** @fileoverview This file exercises two LH reports within the same DOM. */
30
- /** @typedef {import('../clients/bundle.js')} lighthouseRenderer */
31
- /** @type {lighthouseRenderer} */
32
- declare const lighthouseRenderer: lighthouseRenderer;
33
- declare function wait(ms?: number): Promise<any>;
34
- //# sourceMappingURL=faux-psi.d.ts.map