Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: fix timespan/snapshot sticky header #13732

Merged
merged 8 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const flowResult = readJson(
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`
);

/** @type {LH.Result} */
const snapshotLhr = readJson(
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json`
);

const DIST = path.join(LH_ROOT, 'dist');

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

// Generate and write reports
Expand Down
35 changes: 35 additions & 0 deletions lighthouse-core/scripts/update-snapshot-sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
* 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
* 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.
*/
'use strict';

import fs from 'fs';

import puppeteer from 'puppeteer';

import {LH_ROOT} from '../../root.js';
import {snapshot} from '../fraggle-rock/api.js';

(async () => {
const browser = await puppeteer.launch({
ignoreDefaultArgs: ['--enable-automation'],
executablePath: process.env.CHROME_PATH,
headless: false,
});
const page = await browser.newPage();
await page.goto('https://example.com/');

const result = await snapshot({page});
if (!result || typeof result.report !== 'string') {
throw new Error('LHR string not found');
}

fs.writeFileSync(
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json`,
result.report
);

await browser.close();
})();
2,468 changes: 2,468 additions & 0 deletions lighthouse-core/test/fixtures/fraggle-rock/reports/sample-snapshot-lhr.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
"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",
"update:flow-sample-json": "node ./lighthouse-core/scripts/update-flow-fixtures.js",
"update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
"update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
"test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
"open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",
Expand Down
3 changes: 2 additions & 1 deletion report/assets/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
animation: none;
}

.lh-sticky-header .lh-gauge__label {
.lh-sticky-header .lh-gauge__label,
.lh-sticky-header .lh-fraction__label {
display: none;
}

Expand Down
2 changes: 1 addition & 1 deletion report/renderer/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion report/renderer/topbar-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ export class TopbarFeatures {
categoriesAboveTheMiddle.length > 0 ? categoriesAboveTheMiddle.length - 1 : 0;

// Category order matches gauge order in sticky header.
const gaugeWrapperEls = this.stickyHeaderEl.querySelectorAll('.lh-gauge__wrapper');
const gaugeWrapperEls =
this.stickyHeaderEl.querySelectorAll('.lh-gauge__wrapper, .lh-fraction__wrapper');
const gaugeToHighlight = gaugeWrapperEls[highlightIndex];
const origin = gaugeWrapperEls[0].getBoundingClientRect().left;
const offset = gaugeToHighlight.getBoundingClientRect().left - origin;
Expand Down