lighthouse 8.0.0-dev.20210709 → 8.0.0
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.
- package/docs/architecture.md +101 -0
- package/docs/authenticated-pages.md +44 -0
- package/docs/bug-labels.md +35 -0
- package/docs/configuration.md +213 -0
- package/docs/emulation.md +32 -0
- package/docs/error-reporting.md +42 -0
- package/docs/hacking-tips.md +55 -0
- package/docs/headless-chrome.md +119 -0
- package/docs/lantern.md +55 -0
- package/docs/new-audits.md +99 -0
- package/docs/performance-budgets.md +187 -0
- package/docs/plugins.md +374 -0
- package/docs/puppeteer.md +95 -0
- package/docs/readme.md +164 -0
- package/docs/recipes/auth/README.md +129 -0
- package/docs/recipes/auth/example-lh-auth.js +81 -0
- package/docs/recipes/auth/package.json +11 -0
- package/docs/recipes/auth/server/public/dashboard-unauthenticated.html +21 -0
- package/docs/recipes/auth/server/public/dashboard.html +25 -0
- package/docs/recipes/auth/server/public/home-unauthenticated.html +27 -0
- package/docs/recipes/auth/server/public/home.html +17 -0
- package/docs/recipes/auth/server/public/unauthenticated.html +22 -0
- package/docs/recipes/auth/server/server.js +85 -0
- package/docs/recipes/custom-audit/custom-config.js +36 -0
- package/docs/recipes/custom-audit/package.json +8 -0
- package/docs/recipes/custom-audit/readme.md +32 -0
- package/docs/recipes/custom-audit/searchable-audit.js +46 -0
- package/docs/recipes/custom-audit/searchable-gatherer.js +32 -0
- package/docs/recipes/custom-gatherer-puppeteer/custom-audit.js +34 -0
- package/{root.js → docs/recipes/custom-gatherer-puppeteer/custom-config.js} +23 -2
- package/docs/recipes/custom-gatherer-puppeteer/custom-gatherer.js +51 -0
- package/docs/recipes/custom-gatherer-puppeteer/package.json +13 -0
- package/docs/recipes/custom-gatherer-puppeteer/readme.md +7 -0
- package/docs/recipes/custom-gatherer-puppeteer/test.sh +9 -0
- package/docs/recipes/gulp/gulpfile.js +79 -0
- package/docs/recipes/gulp/package.json +12 -0
- package/docs/recipes/gulp/public/index.html +22 -0
- package/docs/recipes/gulp/readme.md +6 -0
- package/docs/recipes/integration-test/README.md +14 -0
- package/docs/recipes/integration-test/example-lh-auth.test.js +160 -0
- package/docs/recipes/integration-test/package.json +9 -0
- package/docs/recipes/lighthouse-plugin-example/audits/preload-as.js +46 -0
- package/docs/recipes/lighthouse-plugin-example/package.json +11 -0
- package/docs/recipes/lighthouse-plugin-example/plugin-recipe-screenshot.png +0 -0
- package/docs/recipes/lighthouse-plugin-example/plugin.js +24 -0
- package/docs/recipes/lighthouse-plugin-example/readme.md +53 -0
- package/docs/releasing.md +164 -0
- package/docs/scoring.md +79 -0
- package/docs/throttling.md +150 -0
- package/docs/understanding-results.md +209 -0
- package/docs/v8-perf-faq.md +244 -0
- package/docs/variability.md +150 -0
- package/jest.config.js +0 -3
- package/lighthouse-cli/bin.js +8 -6
- package/lighthouse-core/audits/accessibility/aria-command-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-meter-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/lighthouse-core/audits/apple-touch-icon.js +0 -1
- package/lighthouse-core/audits/audit.js +3 -3
- package/lighthouse-core/audits/autocomplete.js +2 -2
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +14 -29
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +15 -55
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +4 -8
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +8 -15
- package/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +9 -10
- package/lighthouse-core/audits/byte-efficiency/unminified-css.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +2 -2
- package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +24 -46
- package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
- package/lighthouse-core/audits/critical-request-chains.js +0 -1
- package/lighthouse-core/audits/csp-xss.js +1 -1
- package/lighthouse-core/audits/diagnostics.js +0 -1
- package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +0 -1
- package/lighthouse-core/audits/dobetterweb/inspector-issues.js +1 -1
- package/lighthouse-core/audits/dobetterweb/notification-on-start.js +0 -1
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +0 -1
- package/lighthouse-core/audits/final-screenshot.js +4 -8
- package/lighthouse-core/audits/font-display.js +0 -1
- package/lighthouse-core/audits/installable-manifest.js +3 -4
- package/lighthouse-core/audits/largest-contentful-paint-element.js +0 -1
- package/lighthouse-core/audits/long-tasks.js +1 -1
- package/lighthouse-core/audits/maskable-icon.js +0 -1
- package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -4
- package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/interactive.js +2 -4
- package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -4
- package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -4
- package/lighthouse-core/audits/metrics/speed-index.js +2 -4
- package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -10
- package/lighthouse-core/audits/metrics.js +2 -4
- package/lighthouse-core/audits/performance-budget.js +0 -1
- package/lighthouse-core/audits/predictive-perf.js +6 -9
- package/lighthouse-core/audits/preload-fonts.js +1 -11
- package/lighthouse-core/audits/preload-lcp-image.js +5 -18
- package/lighthouse-core/audits/redirects.js +8 -10
- package/lighthouse-core/audits/screenshot-thumbnails.js +13 -28
- package/lighthouse-core/audits/seo/canonical.js +1 -2
- package/lighthouse-core/audits/seo/font-size.js +4 -4
- package/lighthouse-core/audits/seo/hreflang.js +2 -3
- package/lighthouse-core/audits/seo/http-status-code.js +16 -21
- package/lighthouse-core/audits/seo/is-crawlable.js +3 -4
- package/lighthouse-core/audits/seo/robots-txt.js +2 -2
- package/lighthouse-core/audits/seo/tap-targets.js +5 -5
- package/lighthouse-core/audits/server-response-time.js +2 -20
- package/lighthouse-core/audits/splash-screen.js +0 -1
- package/lighthouse-core/audits/themed-omnibox.js +0 -1
- package/lighthouse-core/audits/third-party-facades.js +0 -1
- package/lighthouse-core/audits/third-party-summary.js +3 -1
- package/lighthouse-core/audits/timing-budget.js +2 -4
- package/lighthouse-core/audits/uses-rel-preconnect.js +9 -14
- package/lighthouse-core/audits/uses-rel-preload.js +2 -13
- package/lighthouse-core/computed/main-thread-tasks.js +2 -2
- package/lighthouse-core/computed/metrics/cumulative-layout-shift.js +3 -3
- package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +6 -6
- package/lighthouse-core/computed/metrics/first-contentful-paint.js +8 -9
- package/lighthouse-core/computed/metrics/first-meaningful-paint.js +9 -10
- package/lighthouse-core/computed/metrics/interactive.js +24 -25
- package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +6 -6
- package/lighthouse-core/computed/metrics/lantern-metric.js +8 -16
- package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +7 -7
- package/lighthouse-core/computed/metrics/largest-contentful-paint.js +9 -10
- package/lighthouse-core/computed/metrics/max-potential-fid.js +11 -8
- package/lighthouse-core/computed/metrics/metric.js +5 -32
- package/lighthouse-core/computed/metrics/speed-index.js +5 -6
- package/lighthouse-core/computed/metrics/timing-summary.js +45 -55
- package/lighthouse-core/computed/metrics/total-blocking-time.js +29 -36
- package/lighthouse-core/computed/page-dependency-graph.js +14 -14
- package/lighthouse-core/computed/resource-summary.js +7 -3
- package/lighthouse-core/computed/speedline.js +3 -3
- package/lighthouse-core/computed/trace-of-tab.js +86 -15
- package/lighthouse-core/computed/user-timings.js +5 -5
- package/lighthouse-core/config/default-config.js +0 -1
- package/lighthouse-core/fraggle-rock/config/config.js +7 -9
- package/lighthouse-core/fraggle-rock/config/default-config.js +2 -40
- package/lighthouse-core/fraggle-rock/config/filters.js +6 -39
- package/lighthouse-core/fraggle-rock/config/validation.js +4 -4
- package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +19 -54
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +10 -21
- package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +2 -2
- package/lighthouse-core/gather/driver/prepare.js +0 -3
- package/lighthouse-core/gather/fetcher.js +2 -0
- package/lighthouse-core/gather/gather-runner.js +14 -2
- package/lighthouse-core/gather/gatherers/image-elements.js +61 -24
- package/lighthouse-core/gather/gatherers/inspector-issues.js +2 -2
- package/lighthouse-core/gather/gatherers/script-elements.js +12 -45
- package/lighthouse-core/gather/gatherers/seo/font-size.js +5 -5
- package/lighthouse-core/gather/gatherers/seo/tap-targets.js +12 -64
- package/lighthouse-core/gather/gatherers/service-worker.js +3 -20
- package/lighthouse-core/gather/gatherers/trace-compat.js +1 -1
- package/lighthouse-core/gather/gatherers/trace-elements.js +3 -15
- package/lighthouse-core/gather/gatherers/trace.js +4 -13
- package/lighthouse-core/gather/gatherers/viewport-dimensions.js +1 -1
- package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +2 -13
- package/lighthouse-core/lib/emulation.js +2 -0
- package/lighthouse-core/lib/i18n/i18n.js +2 -2
- package/lighthouse-core/lib/i18n/locales/ar-XB.json +141 -141
- package/lighthouse-core/lib/i18n/locales/ar.json +143 -143
- package/lighthouse-core/lib/i18n/locales/bg.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ca.json +141 -141
- package/lighthouse-core/lib/i18n/locales/cs.json +141 -141
- package/lighthouse-core/lib/i18n/locales/da.json +141 -141
- package/lighthouse-core/lib/i18n/locales/de.json +142 -142
- package/lighthouse-core/lib/i18n/locales/el.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-GB.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +6659 -0
- package/lighthouse-core/lib/i18n/locales/en-US.json +144 -150
- package/lighthouse-core/lib/i18n/locales/en-XA.json +141 -141
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +6628 -0
- package/lighthouse-core/lib/i18n/locales/en-XL.json +144 -150
- package/lighthouse-core/lib/i18n/locales/es-419.json +141 -141
- package/lighthouse-core/lib/i18n/locales/es.json +141 -141
- package/lighthouse-core/lib/i18n/locales/fi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/fil.json +142 -142
- package/lighthouse-core/lib/i18n/locales/fr.json +141 -141
- package/lighthouse-core/lib/i18n/locales/he.json +142 -142
- package/lighthouse-core/lib/i18n/locales/hi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/hr.json +141 -141
- package/lighthouse-core/lib/i18n/locales/hu.json +143 -143
- package/lighthouse-core/lib/i18n/locales/id.json +143 -143
- package/lighthouse-core/lib/i18n/locales/it.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ja.json +143 -143
- package/lighthouse-core/lib/i18n/locales/ko.json +143 -143
- package/lighthouse-core/lib/i18n/locales/lt.json +143 -143
- package/lighthouse-core/lib/i18n/locales/lv.json +143 -143
- package/lighthouse-core/lib/i18n/locales/nl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/no.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pt-PT.json +141 -141
- package/lighthouse-core/lib/i18n/locales/pt.json +141 -141
- package/lighthouse-core/lib/i18n/locales/ro.json +144 -144
- package/lighthouse-core/lib/i18n/locales/ru.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sk.json +142 -142
- package/lighthouse-core/lib/i18n/locales/sl.json +141 -141
- package/lighthouse-core/lib/i18n/locales/sr-Latn.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sr.json +143 -143
- package/lighthouse-core/lib/i18n/locales/sv.json +142 -142
- package/lighthouse-core/lib/i18n/locales/ta.json +141 -141
- package/lighthouse-core/lib/i18n/locales/te.json +143 -143
- package/lighthouse-core/lib/i18n/locales/th.json +143 -143
- package/lighthouse-core/lib/i18n/locales/tr.json +143 -143
- package/lighthouse-core/lib/i18n/locales/uk.json +141 -141
- package/lighthouse-core/lib/i18n/locales/vi.json +143 -143
- package/lighthouse-core/lib/i18n/locales/zh-HK.json +141 -141
- package/lighthouse-core/lib/i18n/locales/zh-TW.json +143 -143
- package/lighthouse-core/lib/i18n/locales/zh.json +143 -143
- package/lighthouse-core/lib/lh-error.js +2 -2
- package/lighthouse-core/lib/minify-trace.js +1 -1
- package/lighthouse-core/lib/network-request.js +1 -17
- package/lighthouse-core/lib/page-functions.js +5 -6
- package/lighthouse-core/lib/rect-helpers.js +3 -3
- package/lighthouse-core/lib/sd-validation/assets/jsonldcontext.json +7137 -0
- package/lighthouse-core/lib/sd-validation/assets/schema-tree.json +9900 -0
- package/{report/report-assets.js → lighthouse-core/lib/sd-validation/helpers/walk-object.js} +20 -12
- package/lighthouse-core/lib/sd-validation/json-expander.js +56 -0
- package/lighthouse-core/lib/sd-validation/json-linter.js +49 -0
- package/lighthouse-core/lib/sd-validation/jsonld-keyword-validator.js +50 -0
- package/lighthouse-core/lib/sd-validation/line-number-from-jsonld-path.js +60 -0
- package/lighthouse-core/lib/sd-validation/schema-validator.js +146 -0
- package/lighthouse-core/lib/sd-validation/scripts/download-jsonldcontext.js +30 -0
- package/lighthouse-core/lib/sd-validation/scripts/generate-schema-tree.js +97 -0
- package/lighthouse-core/lib/sd-validation/sd-validation.js +77 -0
- package/lighthouse-core/lib/tappable-rects.js +1 -1
- package/lighthouse-core/lib/tracehouse/trace-processor.js +42 -116
- package/lighthouse-core/lib/url-shim.js +2 -29
- package/lighthouse-core/report/html/html-report-assets.js +38 -0
- package/{report/README.md → lighthouse-core/report/html/readme.md} +11 -7
- package/{report → lighthouse-core/report/html}/renderer/category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/crc-details-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/details-renderer.js +1 -1
- package/{report → lighthouse-core/report/html}/renderer/dom.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/element-screenshot-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/i18n.js +1 -1
- package/{report → lighthouse-core/report/html}/renderer/logger.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/performance-category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/psi.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/pwa-category-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/report-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/report-ui-features.js +3 -3
- package/{report → lighthouse-core/report/html}/renderer/snippet-renderer.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/text-encoding.js +0 -0
- package/{report → lighthouse-core/report/html}/renderer/util.js +4 -7
- package/{report/assets/styles.css → lighthouse-core/report/html/report-styles.css} +0 -0
- package/{report/assets/standalone-template.html → lighthouse-core/report/html/report-template.html} +41 -1
- package/{report/assets → lighthouse-core/report/html}/templates.html +0 -0
- package/{report → lighthouse-core/report}/report-generator.js +1 -1
- package/lighthouse-core/runner.js +1 -1
- package/package.json +12 -13
- package/readme.md +2 -2
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -3
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -2
- package/third-party/download-content-shell/download-content-shell.js +1 -2
- package/third-party/snyk/snapshot.json +1 -1
- package/tsconfig.json +1 -0
- package/types/artifacts.d.ts +21 -41
- package/types/audit.d.ts +0 -2
- package/types/config.d.ts +2 -16
- package/types/externs.d.ts +0 -1
- package/types/gatherer.d.ts +13 -13
- package/types/html-renderer.d.ts +14 -14
- package/types/i18n.d.ts +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -94
- package/lighthouse-core/computed/image-records.js +0 -62
- package/lighthouse-core/computed/metrics/navigation-metric.js +0 -46
- package/lighthouse-core/computed/processed-navigation.js +0 -21
- package/lighthouse-core/computed/processed-trace.js +0 -21
- package/lighthouse-core/gather/gatherers/gather-context.js +0 -25
- package/lighthouse-core/gather/gatherers/host-form-factor.js +0 -31
- package/lighthouse-core/gather/gatherers/host-user-agent.js +0 -29
- package/lighthouse-core/lib/lh-trace-processor.js +0 -46
- package/report/clients/standalone.js +0 -52
- package/report/test/renderer/category-renderer-test.js +0 -488
- package/report/test/renderer/crc-details-renderer-test.js +0 -115
- package/report/test/renderer/details-renderer-test.js +0 -843
- package/report/test/renderer/dom-test.js +0 -157
- package/report/test/renderer/element-screenshot-renderer-test.js +0 -189
- package/report/test/renderer/i18n-test.js +0 -146
- package/report/test/renderer/performance-category-renderer-test.js +0 -332
- package/report/test/renderer/psi-test.js +0 -152
- package/report/test/renderer/pwa-category-renderer-test.js +0 -303
- package/report/test/renderer/report-renderer-test.js +0 -325
- package/report/test/renderer/report-ui-features-test.js +0 -572
- package/report/test/renderer/snippet-renderer-test.js +0 -291
- package/report/test/renderer/text-encoding-test.js +0 -41
- package/report/test/renderer/util-test.js +0 -388
- package/report/test/report-generator-test.js +0 -145
|
@@ -1,488 +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
|
-
/* eslint-env jest, browser */
|
|
9
|
-
|
|
10
|
-
const assert = require('assert').strict;
|
|
11
|
-
const jsdom = require('jsdom');
|
|
12
|
-
const reportAssets = require('../../report-assets.js');
|
|
13
|
-
const Util = require('../../renderer/util.js');
|
|
14
|
-
const I18n = require('../../renderer/i18n.js');
|
|
15
|
-
const DOM = require('../../renderer/dom.js');
|
|
16
|
-
const DetailsRenderer = require('../../renderer/details-renderer.js');
|
|
17
|
-
const CriticalRequestChainRenderer = require('../../renderer/crc-details-renderer.js');
|
|
18
|
-
const CategoryRenderer = require('../../renderer/category-renderer.js');
|
|
19
|
-
const sampleResultsOrig = require('../../../lighthouse-core/test/results/sample_v2.json');
|
|
20
|
-
|
|
21
|
-
describe('CategoryRenderer', () => {
|
|
22
|
-
let renderer;
|
|
23
|
-
let sampleResults;
|
|
24
|
-
|
|
25
|
-
beforeAll(() => {
|
|
26
|
-
global.Util = Util;
|
|
27
|
-
global.Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
28
|
-
global.CriticalRequestChainRenderer = CriticalRequestChainRenderer;
|
|
29
|
-
|
|
30
|
-
const {document} = new jsdom.JSDOM(reportAssets.REPORT_TEMPLATES).window;
|
|
31
|
-
const dom = new DOM(document);
|
|
32
|
-
const detailsRenderer = new DetailsRenderer(dom);
|
|
33
|
-
renderer = new CategoryRenderer(dom, detailsRenderer);
|
|
34
|
-
|
|
35
|
-
sampleResults = Util.prepareReportResult(sampleResultsOrig);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
afterAll(() => {
|
|
39
|
-
global.Util.i18n = undefined;
|
|
40
|
-
global.Util = undefined;
|
|
41
|
-
global.CriticalRequestChainRenderer = undefined;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders an audit', () => {
|
|
45
|
-
const auditRef = sampleResults.categories.pwa.auditRefs
|
|
46
|
-
.find(a => a.id === 'installable-manifest');
|
|
47
|
-
|
|
48
|
-
const auditDOM = renderer.renderAudit(auditRef);
|
|
49
|
-
assert.equal(auditDOM.nodeType, 1, 'Audit returns an element');
|
|
50
|
-
|
|
51
|
-
const title = auditDOM.querySelector('.lh-audit__title');
|
|
52
|
-
const description = auditDOM.querySelector('.lh-audit__description');
|
|
53
|
-
|
|
54
|
-
assert.equal(title.textContent, auditRef.result.title);
|
|
55
|
-
assert.ok(description.querySelector('a'), 'audit help text contains coverted markdown links');
|
|
56
|
-
assert.ok(auditDOM.classList.contains('lh-audit--fail'));
|
|
57
|
-
assert.ok(
|
|
58
|
-
auditDOM.classList.contains(`lh-audit--${auditRef.result.scoreDisplayMode.toLowerCase()}`));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('renders an audit explanation when appropriate', () => {
|
|
62
|
-
const audit1 = renderer.renderAudit({
|
|
63
|
-
result: {
|
|
64
|
-
title: 'Audit title',
|
|
65
|
-
explanation: 'A reason',
|
|
66
|
-
description: 'help text',
|
|
67
|
-
scoreDisplayMode: 'binary',
|
|
68
|
-
score: 0,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
assert.ok(audit1.querySelector('.lh-audit-explanation'));
|
|
72
|
-
|
|
73
|
-
const audit2 = renderer.renderAudit({
|
|
74
|
-
result: {
|
|
75
|
-
title: 'Audit title',
|
|
76
|
-
description: 'help text',
|
|
77
|
-
scoreDisplayMode: 'binary',
|
|
78
|
-
score: 0,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
assert.ok(!audit2.querySelector('.lh-audit-explanation'));
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('renders an informative audit', () => {
|
|
85
|
-
const auditDOM = renderer.renderAudit({
|
|
86
|
-
id: 'informative',
|
|
87
|
-
result: {
|
|
88
|
-
title: 'It informs',
|
|
89
|
-
description: 'help text',
|
|
90
|
-
scoreDisplayMode: 'informative',
|
|
91
|
-
score: 0,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
assert.ok(auditDOM.matches('.lh-audit--informative'));
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('adds a pass/average/fail class for non-informative audits', () => {
|
|
98
|
-
const auditDOM = renderer.renderAudit({
|
|
99
|
-
id: 'not-informative',
|
|
100
|
-
result: {
|
|
101
|
-
title: 'Not informative',
|
|
102
|
-
description: 'help text',
|
|
103
|
-
scoreDisplayMode: 'numeric',
|
|
104
|
-
score: 0,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
assert.ok(auditDOM.matches('.lh-audit--fail'));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('does not add a pass/average/fail class for informative audits', () => {
|
|
111
|
-
const auditDOM = renderer.renderAudit({
|
|
112
|
-
id: 'informative',
|
|
113
|
-
result: {
|
|
114
|
-
title: 'It informs',
|
|
115
|
-
description: 'help text',
|
|
116
|
-
scoreDisplayMode: 'informative',
|
|
117
|
-
score: 0,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
assert.equal(auditDOM.classList.length, 2);
|
|
121
|
-
assert.ok(auditDOM.matches('.lh-audit'));
|
|
122
|
-
assert.ok(auditDOM.matches('.lh-audit--informative'));
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('renders audits with a warning', () => {
|
|
126
|
-
const auditResult = {
|
|
127
|
-
title: 'Audit',
|
|
128
|
-
description: 'Learn more',
|
|
129
|
-
scoreDisplayMode: 'informative',
|
|
130
|
-
warnings: ['It may not have worked!'],
|
|
131
|
-
score: 1,
|
|
132
|
-
};
|
|
133
|
-
const auditDOM = renderer.renderAudit({id: 'foo', result: auditResult});
|
|
134
|
-
const warningEl = auditDOM.querySelector('.lh-warnings');
|
|
135
|
-
assert.ok(warningEl, 'did not render warning message');
|
|
136
|
-
assert.ok(warningEl.textContent.includes(auditResult.warnings[0]), 'warning message provided');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('renders audits with multiple warnings', () => {
|
|
140
|
-
const auditResult = {
|
|
141
|
-
title: 'Audit',
|
|
142
|
-
description: 'Learn more',
|
|
143
|
-
scoreDisplayMode: 'informative',
|
|
144
|
-
warnings: ['It may not have worked!', 'You should read this, though'],
|
|
145
|
-
score: 1,
|
|
146
|
-
};
|
|
147
|
-
const auditDOM = renderer.renderAudit({id: 'foo', result: auditResult});
|
|
148
|
-
const warningEl = auditDOM.querySelector('.lh-warnings');
|
|
149
|
-
assert.ok(warningEl, 'did not render warning message');
|
|
150
|
-
assert.ok(warningEl.textContent.includes(auditResult.warnings[0]), '1st warning provided');
|
|
151
|
-
assert.ok(warningEl.textContent.includes(auditResult.warnings[1]), '2nd warning provided');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('renders a category', () => {
|
|
155
|
-
const category = sampleResults.categories.pwa;
|
|
156
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
157
|
-
|
|
158
|
-
const categoryEl = categoryDOM.querySelector('.lh-category-header');
|
|
159
|
-
const value = categoryDOM.querySelector('.lh-gauge__percentage');
|
|
160
|
-
const title = categoryEl.querySelector('.lh-gauge__label');
|
|
161
|
-
|
|
162
|
-
assert.deepEqual(categoryEl, categoryEl.firstElementChild, 'first child is a score');
|
|
163
|
-
const scoreInDom = Number(value.textContent);
|
|
164
|
-
assert.ok(Number.isInteger(scoreInDom) && scoreInDom > 10, 'category score is rounded');
|
|
165
|
-
assert.equal(title.textContent, category.title, 'title is set');
|
|
166
|
-
|
|
167
|
-
const audits = categoryDOM.querySelectorAll('.lh-audit');
|
|
168
|
-
assert.equal(audits.length, category.auditRefs.length, 'renders correct number of audits');
|
|
169
|
-
|
|
170
|
-
// No plugin categories in sampleResults.
|
|
171
|
-
assert.equal(
|
|
172
|
-
categoryDOM.querySelector('.lh-gauge__wrapper--plugin'), null, 'renders no plugin badges');
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('plugin category has plugin badge', () => {
|
|
176
|
-
const category = JSON.parse(
|
|
177
|
-
JSON.stringify(sampleResults.categories.seo));
|
|
178
|
-
category.id = 'lighthouse-plugin-someplugin';
|
|
179
|
-
category.title = 'Some Plugin';
|
|
180
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
181
|
-
assert.ok(categoryDOM.querySelector('.lh-gauge__wrapper--plugin'));
|
|
182
|
-
const label = categoryDOM.querySelector('.lh-gauge__label').textContent;
|
|
183
|
-
assert.equal(category.title, label);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('handles markdown in category descriptions a category', () => {
|
|
187
|
-
const category = sampleResults.categories.pwa;
|
|
188
|
-
const prevDesc = category.description;
|
|
189
|
-
category.description += ' [link text](http://example.com).';
|
|
190
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
191
|
-
const description = categoryDOM.querySelector('.lh-category-header__description');
|
|
192
|
-
assert.ok(description.querySelector('a'), 'description contains converted markdown links');
|
|
193
|
-
category.description = prevDesc;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('renders manual audits if the category contains them', () => {
|
|
197
|
-
const pwaCategory = sampleResults.categories.pwa;
|
|
198
|
-
const categoryDOM = renderer.render(pwaCategory, sampleResults.categoryGroups);
|
|
199
|
-
assert.ok(categoryDOM.querySelector('.lh-clump--manual .lh-audit-group__summary'));
|
|
200
|
-
assert.equal(categoryDOM.querySelectorAll('.lh-audit--manual').length, 3,
|
|
201
|
-
'score shows informative and dash icon');
|
|
202
|
-
|
|
203
|
-
assert.ok(pwaCategory.manualDescription);
|
|
204
|
-
const description = categoryDOM
|
|
205
|
-
.querySelector('.lh-clump--manual .lh-audit-group__description').textContent;
|
|
206
|
-
// may need to be adjusted if description includes a link at the beginning
|
|
207
|
-
assert.ok(description.startsWith(pwaCategory.manualDescription.substring(0, 20)),
|
|
208
|
-
'no manual description');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe('categories with not applicable audits', () => {
|
|
212
|
-
let a11yCategory;
|
|
213
|
-
|
|
214
|
-
beforeEach(()=> {
|
|
215
|
-
a11yCategory = JSON.parse(JSON.stringify(sampleResults.categories.accessibility));
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('renders not applicable audits if the category contains them', () => {
|
|
219
|
-
const categoryDOM = renderer.render(a11yCategory, sampleResults.categoryGroups);
|
|
220
|
-
assert.ok(categoryDOM.querySelector(
|
|
221
|
-
'.lh-clump--notapplicable .lh-audit-group__summary'));
|
|
222
|
-
|
|
223
|
-
const notApplicableCount = a11yCategory.auditRefs.reduce((sum, audit) =>
|
|
224
|
-
sum += audit.result.scoreDisplayMode === 'notApplicable' ? 1 : 0, 0);
|
|
225
|
-
assert.equal(
|
|
226
|
-
categoryDOM.querySelectorAll('.lh-clump--notapplicable .lh-audit').length,
|
|
227
|
-
notApplicableCount,
|
|
228
|
-
'score shows informative and dash icon'
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it('does not render a not applicable section if the category does not contain them', () => {
|
|
233
|
-
const category = sampleResults.categories['best-practices'];
|
|
234
|
-
const bestPracticeCat = {
|
|
235
|
-
...category,
|
|
236
|
-
auditRefs: category.auditRefs
|
|
237
|
-
.filter(ref => ref.result.scoreDisplayMode !== 'notApplicable'),
|
|
238
|
-
};
|
|
239
|
-
const categoryDOM2 = renderer.render(bestPracticeCat, sampleResults.categoryGroups);
|
|
240
|
-
assert.ok(!categoryDOM2.querySelector('.lh-clump--notapplicable'));
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('renders a dash score if the category contains 0 applicable audits', () => {
|
|
244
|
-
for (const auditRef of a11yCategory.auditRefs) {
|
|
245
|
-
auditRef.result.scoreDisplayMode = 'notApplicable';
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const categoryDOM = renderer.render(a11yCategory, sampleResults.categoryGroups);
|
|
249
|
-
const percentageEl = categoryDOM.querySelectorAll('[title="Not applicable"]');
|
|
250
|
-
|
|
251
|
-
assert.equal(percentageEl[0].textContent, '-', 'score shows a dash');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('renders a non-dash score if the category contains at least 1 applicable audit', () => {
|
|
255
|
-
for (const auditRef of a11yCategory.auditRefs) {
|
|
256
|
-
auditRef.result.scoreDisplayMode = 'notApplicable';
|
|
257
|
-
}
|
|
258
|
-
a11yCategory.auditRefs[0].result.scoreDisplayMode = 'numeric';
|
|
259
|
-
|
|
260
|
-
const categoryDOM = renderer.render(a11yCategory, sampleResults.categoryGroups);
|
|
261
|
-
const percentageEl = categoryDOM.querySelectorAll('.lh-gauge__percentage');
|
|
262
|
-
|
|
263
|
-
assert.equal(percentageEl[0].textContent, '81', 'score shows a non-dash value');
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe('category with groups', () => {
|
|
268
|
-
let category;
|
|
269
|
-
|
|
270
|
-
beforeEach(() => {
|
|
271
|
-
category = sampleResults.categories.accessibility;
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it('renders the category header', () => {
|
|
275
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
276
|
-
|
|
277
|
-
const gauge = categoryDOM.querySelector('.lh-gauge__percentage');
|
|
278
|
-
assert.equal(gauge.textContent.trim(), '81', 'score is 0-100');
|
|
279
|
-
|
|
280
|
-
const score = categoryDOM.querySelector('.lh-category-header');
|
|
281
|
-
const value = categoryDOM.querySelector('.lh-gauge__percentage');
|
|
282
|
-
const title = score.querySelector('.lh-gauge__label');
|
|
283
|
-
const description = score.querySelector('.lh-category-header__description');
|
|
284
|
-
|
|
285
|
-
assert.deepEqual(score, score.firstElementChild, 'first child is a score');
|
|
286
|
-
const scoreInDom = Number(value.textContent);
|
|
287
|
-
assert.ok(Number.isInteger(scoreInDom) && scoreInDom > 10, 'score is rounded out of 100');
|
|
288
|
-
assert.equal(title.textContent, category.title, 'title is set');
|
|
289
|
-
assert.ok(description.querySelector('a'), 'description contains converted markdown links');
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('renders the failed audits grouped by group', () => {
|
|
293
|
-
// Fail all the audits.
|
|
294
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
295
|
-
const auditRefs = categoryClone.auditRefs;
|
|
296
|
-
auditRefs.forEach(ref => {
|
|
297
|
-
ref.result.score = 0;
|
|
298
|
-
ref.result.scoreDisplayMode = 'binary';
|
|
299
|
-
});
|
|
300
|
-
const categoryDOM = renderer.render(categoryClone, sampleResults.categoryGroups);
|
|
301
|
-
|
|
302
|
-
// All the group names in the config.
|
|
303
|
-
const groupNames = Array.from(new Set(auditRefs.map(ref => ref.group))).filter(Boolean);
|
|
304
|
-
assert.ok(groupNames.length > 5, `not enough groups found in category for test`);
|
|
305
|
-
|
|
306
|
-
// All the group roots in the DOM.
|
|
307
|
-
const failedGroupElems = Array.from(
|
|
308
|
-
categoryDOM.querySelectorAll('.lh-clump--failed > .lh-audit-group'));
|
|
309
|
-
|
|
310
|
-
assert.strictEqual(failedGroupElems.length, groupNames.length);
|
|
311
|
-
|
|
312
|
-
for (const groupName of groupNames) {
|
|
313
|
-
const groupAuditRefs = auditRefs.filter(ref => ref.group === groupName);
|
|
314
|
-
assert.ok(groupAuditRefs.length > 0, `no auditRefs found with group '${groupName}'`);
|
|
315
|
-
|
|
316
|
-
const className = `lh-audit-group--${groupName}`;
|
|
317
|
-
const groupElem = failedGroupElems.find(el => el.classList.contains(className));
|
|
318
|
-
const groupAuditElems = groupElem.querySelectorAll('.lh-audit');
|
|
319
|
-
|
|
320
|
-
assert.strictEqual(groupAuditElems.length, groupAuditRefs.length);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('renders the passed audits ungrouped', () => {
|
|
325
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
326
|
-
const passedAudits = category.auditRefs.filter(audit =>
|
|
327
|
-
audit.result.scoreDisplayMode !== 'notApplicable' && audit.result.score === 1);
|
|
328
|
-
|
|
329
|
-
const passedAuditGroups = categoryDOM.querySelectorAll('.lh-clump--passed .lh-audit-group');
|
|
330
|
-
const passedAuditsElems = categoryDOM.querySelectorAll('.lh-clump--passed .lh-audit');
|
|
331
|
-
|
|
332
|
-
assert.equal(passedAuditGroups.length, 0);
|
|
333
|
-
assert.equal(passedAuditsElems.length, passedAudits.length);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it('renders all the audits', () => {
|
|
337
|
-
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
|
|
338
|
-
const auditsElements = categoryDOM.querySelectorAll('.lh-audit');
|
|
339
|
-
assert.equal(auditsElements.length, category.auditRefs.length);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('renders audits without a group before grouped ones', () => {
|
|
343
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
344
|
-
|
|
345
|
-
// Remove groups from some audits.
|
|
346
|
-
const ungroupedAudits = ['image-alt', 'link-name'];
|
|
347
|
-
for (const auditRef of categoryClone.auditRefs) {
|
|
348
|
-
if (ungroupedAudits.includes(auditRef.id)) {
|
|
349
|
-
assert.ok(auditRef.group); // Make sure this will change something.
|
|
350
|
-
delete auditRef.group;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const elem = renderer.render(categoryClone, sampleResults.categoryGroups);
|
|
355
|
-
|
|
356
|
-
// Check that the first audits found are the ungrouped ones.
|
|
357
|
-
const auditElems = Array.from(elem.querySelectorAll('.lh-audit'));
|
|
358
|
-
const firstAuditElems = auditElems.slice(0, ungroupedAudits.length);
|
|
359
|
-
for (const auditElem of firstAuditElems) {
|
|
360
|
-
const auditId = auditElem.id;
|
|
361
|
-
assert.ok(ungroupedAudits.includes(auditId), auditId);
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
it('gives each group a selectable class', () => {
|
|
366
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
367
|
-
// Force all results to be Failed for accurate counting of groups.
|
|
368
|
-
categoryClone.auditRefs.forEach(ref => {
|
|
369
|
-
ref.result.score = 0;
|
|
370
|
-
ref.result.scoreDisplayMode = 'binary';
|
|
371
|
-
});
|
|
372
|
-
const categoryGroupIds = new Set(category.auditRefs.filter(a => a.group).map(a => a.group));
|
|
373
|
-
assert.ok(categoryGroupIds.size > 6); // Ensure there's something to test.
|
|
374
|
-
|
|
375
|
-
const categoryElem = renderer.render(categoryClone, sampleResults.categoryGroups);
|
|
376
|
-
|
|
377
|
-
categoryGroupIds.forEach(groupId => {
|
|
378
|
-
const selector = `.lh-audit-group--${groupId}`;
|
|
379
|
-
assert.equal(categoryElem.querySelectorAll(selector).length, 1,
|
|
380
|
-
`could not find '${selector}'`);
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
describe('clumping passed/failed/warning/manual', () => {
|
|
386
|
-
it('separates audits in the DOM', () => {
|
|
387
|
-
const category = sampleResults.categories.pwa;
|
|
388
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
389
|
-
// Give the first two passing grades warnings
|
|
390
|
-
const passingRefs = categoryClone.auditRefs.filter(ref => ref.result.score === 1);
|
|
391
|
-
passingRefs[0].result.warnings = ['Some warning'];
|
|
392
|
-
passingRefs[1].result.warnings = ['Some warning'];
|
|
393
|
-
|
|
394
|
-
const elem = renderer.render(categoryClone, sampleResults.categoryGroups);
|
|
395
|
-
const passedAudits = elem.querySelectorAll('.lh-clump--passed .lh-audit');
|
|
396
|
-
const failedAudits = elem.querySelectorAll('.lh-clump--failed .lh-audit');
|
|
397
|
-
const warningAudits = elem.querySelectorAll('.lh-clump--warning .lh-audit');
|
|
398
|
-
const manualAudits = elem.querySelectorAll('.lh-clump--manual .lh-audit');
|
|
399
|
-
const naAudits = elem.querySelectorAll('.lh-clump--notapplicable .lh-audit');
|
|
400
|
-
|
|
401
|
-
assert.equal(passedAudits.length, 0);
|
|
402
|
-
assert.equal(failedAudits.length, 6);
|
|
403
|
-
assert.equal(warningAudits.length, 2);
|
|
404
|
-
assert.equal(manualAudits.length, 3);
|
|
405
|
-
assert.equal(naAudits.length, 1);
|
|
406
|
-
|
|
407
|
-
const allAudits = elem.querySelectorAll('.lh-audit');
|
|
408
|
-
// No unaccounted audits
|
|
409
|
-
assert.equal(allAudits.length - passedAudits.length - failedAudits.length -
|
|
410
|
-
warningAudits.length - manualAudits.length - naAudits.length, 0);
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it('doesnt create a passed section if there were 0 passed', () => {
|
|
414
|
-
const origCategory = sampleResults.categories.pwa;
|
|
415
|
-
const category = JSON.parse(JSON.stringify(origCategory));
|
|
416
|
-
category.auditRefs.forEach(audit => audit.result.score = 0);
|
|
417
|
-
const elem = renderer.render(category, sampleResults.categoryGroups);
|
|
418
|
-
const passedAudits = elem.querySelectorAll('.lh-clump--passed .lh-audit');
|
|
419
|
-
const failedAudits = elem.querySelectorAll('.lh-clump--failed .lh-audit');
|
|
420
|
-
|
|
421
|
-
assert.equal(passedAudits.length, 0);
|
|
422
|
-
assert.equal(failedAudits.length, 8);
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
it('expands warning audit group', () => {
|
|
426
|
-
const category = sampleResults.categories.pwa;
|
|
427
|
-
const categoryClone = JSON.parse(JSON.stringify(category));
|
|
428
|
-
const failingAudit = categoryClone.auditRefs.find(ref => ref.id === 'content-width');
|
|
429
|
-
failingAudit.result.warnings = ['Some warning'];
|
|
430
|
-
|
|
431
|
-
const auditDOM = renderer.render(categoryClone, sampleResults.categoryGroups);
|
|
432
|
-
const warningClumpEl = auditDOM.querySelector('.lh-clump--warning');
|
|
433
|
-
const isExpanded = warningClumpEl.hasAttribute('open');
|
|
434
|
-
assert.ok(isExpanded, 'Warning audit group should be expanded by default');
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('only passing audits with warnings show in warnings section', () => {
|
|
438
|
-
const failingWarning = 'Failed and warned';
|
|
439
|
-
const passingWarning = 'A passing warning';
|
|
440
|
-
const category = {
|
|
441
|
-
id: 'test',
|
|
442
|
-
title: 'Test',
|
|
443
|
-
score: 0,
|
|
444
|
-
auditRefs: [{
|
|
445
|
-
id: 'failing',
|
|
446
|
-
result: {
|
|
447
|
-
id: 'failing',
|
|
448
|
-
title: 'Failing with warning',
|
|
449
|
-
description: '',
|
|
450
|
-
scoreDisplayMode: 'numeric',
|
|
451
|
-
score: 0,
|
|
452
|
-
warnings: [failingWarning],
|
|
453
|
-
},
|
|
454
|
-
}, {
|
|
455
|
-
id: 'passing',
|
|
456
|
-
result: {
|
|
457
|
-
id: 'passing',
|
|
458
|
-
title: 'Passing with warning',
|
|
459
|
-
description: '',
|
|
460
|
-
scoreDisplayMode: 'numeric',
|
|
461
|
-
score: 1,
|
|
462
|
-
warnings: [passingWarning],
|
|
463
|
-
},
|
|
464
|
-
}],
|
|
465
|
-
};
|
|
466
|
-
const categoryDOM = renderer.render(category);
|
|
467
|
-
|
|
468
|
-
const shouldBeFailed = categoryDOM.querySelectorAll('.lh-clump--failed .lh-audit');
|
|
469
|
-
assert.strictEqual(shouldBeFailed.length, 1);
|
|
470
|
-
assert.strictEqual(shouldBeFailed[0].id, 'failing');
|
|
471
|
-
assert.ok(shouldBeFailed[0].textContent.includes(failingWarning));
|
|
472
|
-
|
|
473
|
-
const shouldBeWarning = categoryDOM.querySelectorAll('.lh-clump--warning .lh-audit');
|
|
474
|
-
assert.strictEqual(shouldBeWarning.length, 1);
|
|
475
|
-
assert.strictEqual(shouldBeWarning[0].id, 'passing');
|
|
476
|
-
assert.ok(shouldBeWarning[0].textContent.includes(passingWarning));
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
it('can set a custom templateContext', () => {
|
|
481
|
-
assert.equal(renderer.templateContext, renderer.dom.document());
|
|
482
|
-
|
|
483
|
-
const dom = new jsdom.JSDOM(reportAssets.REPORT_TEMPLATES);
|
|
484
|
-
const otherDocument = dom.window.document;
|
|
485
|
-
renderer.setTemplateContext(otherDocument);
|
|
486
|
-
assert.equal(renderer.templateContext, otherDocument);
|
|
487
|
-
});
|
|
488
|
-
});
|
|
@@ -1,115 +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
|
-
/* eslint-env jest */
|
|
9
|
-
|
|
10
|
-
const assert = require('assert').strict;
|
|
11
|
-
const jsdom = require('jsdom');
|
|
12
|
-
const reportAssets = require('../../report-assets.js');
|
|
13
|
-
const Util = require('../../renderer/util.js');
|
|
14
|
-
const I18n = require('../../renderer/i18n.js');
|
|
15
|
-
const DOM = require('../../renderer/dom.js');
|
|
16
|
-
const DetailsRenderer = require('../../renderer/details-renderer.js');
|
|
17
|
-
const CriticalRequestChainRenderer = require('../../renderer/crc-details-renderer.js');
|
|
18
|
-
|
|
19
|
-
const superLongURL =
|
|
20
|
-
'https://example.com/thisIsASuperLongURLThatWillTriggerFilenameTruncationWhichWeWantToTest.js';
|
|
21
|
-
const DETAILS = {
|
|
22
|
-
type: 'criticalrequestchain',
|
|
23
|
-
chains: {
|
|
24
|
-
0: {
|
|
25
|
-
request: {
|
|
26
|
-
endTime: 1,
|
|
27
|
-
responseReceivedTime: 5,
|
|
28
|
-
startTime: 0,
|
|
29
|
-
url: 'https://example.com/',
|
|
30
|
-
transferSize: 1000,
|
|
31
|
-
},
|
|
32
|
-
children: {
|
|
33
|
-
1: {
|
|
34
|
-
request: {
|
|
35
|
-
endTime: 16,
|
|
36
|
-
responseReceivedTime: 14,
|
|
37
|
-
startTime: 11,
|
|
38
|
-
url: 'https://example.com/b.js',
|
|
39
|
-
transferSize: 2000,
|
|
40
|
-
},
|
|
41
|
-
children: {},
|
|
42
|
-
},
|
|
43
|
-
2: {
|
|
44
|
-
request: {
|
|
45
|
-
endTime: 17.123456789,
|
|
46
|
-
responseReceivedTime: 15,
|
|
47
|
-
startTime: 12,
|
|
48
|
-
url: superLongURL,
|
|
49
|
-
transferSize: 3000,
|
|
50
|
-
},
|
|
51
|
-
children: {},
|
|
52
|
-
},
|
|
53
|
-
3: {
|
|
54
|
-
request: {
|
|
55
|
-
endTime: 18,
|
|
56
|
-
responseReceivedTime: 16,
|
|
57
|
-
startTime: 13,
|
|
58
|
-
url: 'about:blank',
|
|
59
|
-
transferSize: 4000,
|
|
60
|
-
},
|
|
61
|
-
children: {},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
longestChain: {
|
|
67
|
-
duration: 7000,
|
|
68
|
-
length: 2,
|
|
69
|
-
transferSize: 1,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
describe('DetailsRenderer', () => {
|
|
74
|
-
let dom;
|
|
75
|
-
let detailsRenderer;
|
|
76
|
-
|
|
77
|
-
beforeAll(() => {
|
|
78
|
-
global.Util = Util;
|
|
79
|
-
global.Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
80
|
-
const {document} = new jsdom.JSDOM(reportAssets.REPORT_TEMPLATES).window;
|
|
81
|
-
dom = new DOM(document);
|
|
82
|
-
detailsRenderer = new DetailsRenderer(dom);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
afterAll(() => {
|
|
86
|
-
global.Util.i18n = undefined;
|
|
87
|
-
global.Util = undefined;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('renders tree structure', () => {
|
|
91
|
-
const el = CriticalRequestChainRenderer.render(dom, dom.document(), DETAILS, detailsRenderer);
|
|
92
|
-
const chains = el.querySelectorAll('.crc-node');
|
|
93
|
-
|
|
94
|
-
// Main request
|
|
95
|
-
assert.equal(chains.length, 4, 'generates correct number of chain nodes');
|
|
96
|
-
assert.ok(!chains[0].querySelector('.lh-text__url-host'), 'should be no origin for root url');
|
|
97
|
-
assert.equal(chains[0].querySelector('.lh-text__url a').textContent, 'https://example.com');
|
|
98
|
-
assert.equal(chains[0].querySelector('.lh-text__url a').href, 'https://example.com/');
|
|
99
|
-
assert.equal(chains[0].querySelector('.lh-text__url a').rel, 'noopener');
|
|
100
|
-
assert.equal(chains[0].querySelector('.lh-text__url a').target, '_blank');
|
|
101
|
-
|
|
102
|
-
// Children
|
|
103
|
-
assert.ok(chains[1].querySelector('.crc-node__tree-marker .vert-right'));
|
|
104
|
-
assert.equal(chains[1].querySelectorAll('.crc-node__tree-marker .right').length, 2);
|
|
105
|
-
assert.equal(chains[1].querySelector('.lh-text__url a').textContent, '/b.js');
|
|
106
|
-
assert.equal(chains[1].querySelector('.lh-text__url a').href, 'https://example.com/b.js');
|
|
107
|
-
assert.equal(chains[1].querySelector('.lh-text__url a').rel, 'noopener');
|
|
108
|
-
assert.equal(chains[1].querySelector('.lh-text__url a').target, '_blank');
|
|
109
|
-
assert.equal(chains[1].querySelector('.lh-text__url-host').textContent, '(example.com)');
|
|
110
|
-
const durationNodes = chains[1].querySelectorAll('.crc-node__chain-duration');
|
|
111
|
-
assert.equal(durationNodes[0].textContent, ' - 5,000\xa0ms, ');
|
|
112
|
-
// Note: actual transferSize is 2000 bytes but formatter formats to KiBs.
|
|
113
|
-
assert.equal(durationNodes[1].textContent, '1.95\xa0KiB');
|
|
114
|
-
});
|
|
115
|
-
});
|