diff --git a/core/audits/insights/image-delivery-insight.js b/core/audits/insights/image-delivery-insight.js index 3b5f7c9fa2e0..e62c9e16397d 100644 --- a/core/audits/insights/image-delivery-insight.js +++ b/core/audits/insights/image-delivery-insight.js @@ -60,6 +60,8 @@ class ImageDeliveryInsight extends Audit { wastedBytes: image.byteSavings, subItems: { type: /** @type {const} */ ('subitems'), + // TODO: when strings update to remove number from "reason" uistrings, update this + // to use `image.optimizations.map(...)` and construct strings from the type. items: (relatedEventsMap?.get(image.request) ?? []).map((reason, i) => ({ reason, wastedBytes: image.optimizations[i].byteSavings, diff --git a/core/audits/insights/insight-audit.js b/core/audits/insights/insight-audit.js index 1c840c4b3af0..e21d7384c1e9 100644 --- a/core/audits/insights/insight-audit.js +++ b/core/audits/insights/insight-audit.js @@ -71,10 +71,16 @@ async function adaptInsightToAuditProduct(artifacts, context, insightName, creat metricSavings = {...metricSavings, LCP: /** @type {any} */ (0)}; } + let score = insight.shouldShow ? 0 : 1; + // TODO: change insight model to denote passing/failing/informative. Until then... hack it. + if (insightName === 'LCPPhases') { + score = metricSavings?.LCP ?? 0 >= 1000 ? 0 : 1; + } + return { scoreDisplayMode: insight.metricSavings ? Audit.SCORING_MODES.METRIC_SAVINGS : Audit.SCORING_MODES.NUMERIC, - score: insight.shouldShow ? 0 : 1, + score, metricSavings, warnings: insight.warnings, details, diff --git a/core/test/fixtures/user-flows/reports/sample-flow-result.json b/core/test/fixtures/user-flows/reports/sample-flow-result.json index 2ac9ca539e33..776748060cf2 100644 --- a/core/test/fixtures/user-flows/reports/sample-flow-result.json +++ b/core/test/fixtures/user-flows/reports/sample-flow-result.json @@ -3994,7 +3994,7 @@ "id": "lcp-phases-insight", "title": "LCP by phase", "description": "Each [phase has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.", - "score": 0, + "score": 1, "scoreDisplayMode": "numeric", "metricSavings": { "LCP": 0 @@ -23087,7 +23087,7 @@ "id": "lcp-phases-insight", "title": "LCP by phase", "description": "Each [phase has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.", - "score": 0, + "score": 1, "scoreDisplayMode": "numeric", "metricSavings": { "LCP": 0 diff --git a/core/test/results/sample_v2.json b/core/test/results/sample_v2.json index 89b701c17de0..f4c1bc370ad6 100644 --- a/core/test/results/sample_v2.json +++ b/core/test/results/sample_v2.json @@ -6107,7 +6107,7 @@ "id": "lcp-phases-insight", "title": "LCP by phase", "description": "Each [phase has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.", - "score": 0, + "score": 1, "scoreDisplayMode": "numeric", "metricSavings": { "LCP": 0