Skip to content

Commit f0a30a3

Browse files
authoredMar 9, 2022
report: fix timespan/snapshot sticky header (#13732)
1 parent f7ca582 commit f0a30a3

File tree

7 files changed

+2515
-3
lines changed

7 files changed

+2515
-3
lines changed
 

‎build/build-sample-reports.js

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const flowResult = readJson(
2323
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`
2424
);
2525

26+
/** @type {LH.Result} */
27+
const snapshotLhr = readJson(
28+
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json`
29+
);
30+
2631
const DIST = path.join(LH_ROOT, 'dist');
2732

2833
(async function() {
@@ -36,6 +41,7 @@ const DIST = path.join(LH_ROOT, 'dist');
3641
'xl-accented': swapLocale(lhr, 'en-XL').lhr,
3742
'error': errorLhr,
3843
'single-category': tweakLhrForPsi(lhr),
44+
'snapshot': snapshotLhr,
3945
};
4046

4147
// Generate and write reports
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license Copyright 2022 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 fs from 'fs';
9+
10+
import puppeteer from 'puppeteer';
11+
12+
import {LH_ROOT} from '../../root.js';
13+
import {snapshot} from '../fraggle-rock/api.js';
14+
15+
(async () => {
16+
const browser = await puppeteer.launch({
17+
ignoreDefaultArgs: ['--enable-automation'],
18+
executablePath: process.env.CHROME_PATH,
19+
headless: false,
20+
});
21+
const page = await browser.newPage();
22+
await page.goto('https://example.com/');
23+
24+
const result = await snapshot({page});
25+
if (!result || typeof result.report !== 'string') {
26+
throw new Error('LHR string not found');
27+
}
28+
29+
fs.writeFileSync(
30+
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json`,
31+
result.report
32+
);
33+
34+
await browser.close();
35+
})();

‎lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json

+2,468
Large diffs are not rendered by default.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
7777
"update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
7878
"update:flow-sample-json": "node ./lighthouse-core/scripts/update-flow-fixtures.js",
79+
"update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
7980
"update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
8081
"test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
8182
"open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",

‎report/assets/templates.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
animation: none;
190190
}
191191

192-
.lh-sticky-header .lh-gauge__label {
192+
.lh-sticky-header .lh-gauge__label,
193+
.lh-sticky-header .lh-fraction__label {
193194
display: none;
194195
}
195196

‎report/renderer/components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎report/renderer/topbar-features.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ export class TopbarFeatures {
306306
categoriesAboveTheMiddle.length > 0 ? categoriesAboveTheMiddle.length - 1 : 0;
307307

308308
// Category order matches gauge order in sticky header.
309-
const gaugeWrapperEls = this.stickyHeaderEl.querySelectorAll('.lh-gauge__wrapper');
309+
const gaugeWrapperEls =
310+
this.stickyHeaderEl.querySelectorAll('.lh-gauge__wrapper, .lh-fraction__wrapper');
310311
const gaugeToHighlight = gaugeWrapperEls[highlightIndex];
311312
const origin = gaugeWrapperEls[0].getBoundingClientRect().left;
312313
const offset = gaugeToHighlight.getBoundingClientRect().left - origin;

0 commit comments

Comments
 (0)