From d486855e29c5bc059582ca5acca2557656be403f Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Mon, 25 Apr 2022 16:09:13 -0700 Subject: [PATCH] report: handle non-numeric numericValues in calc link (#10880) --- .../renderer/performance-category-renderer-test.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/report/test/renderer/performance-category-renderer-test.js b/report/test/renderer/performance-category-renderer-test.js index 7ac8c75ac5a5..19fed9af0a9e 100644 --- a/report/test/renderer/performance-category-renderer-test.js +++ b/report/test/renderer/performance-category-renderer-test.js @@ -328,7 +328,7 @@ Array [ } }); - it('uses null if the metric is missing its value', () => { + it('uses null if the metric\'s value is undefined', () => { const categoryClone = JSON.parse(JSON.stringify(category)); const lcp = categoryClone.auditRefs.find(audit => audit.id === 'largest-contentful-paint'); lcp.result.numericValue = undefined; @@ -336,6 +336,16 @@ Array [ const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs); expect(href).toContain('LCP=null'); }); + + it('uses null if the metric\'s value is null (LR)', () => { + const categoryClone = JSON.parse(JSON.stringify(category)); + const lcp = categoryClone.auditRefs.find(audit => audit.id === 'largest-contentful-paint'); + // In LR, we think there might be some case where undefined becomes null, but we can't prove it. + lcp.result.numericValue = null; + lcp.result.score = null; + const href = renderer._getScoringCalculatorHref(categoryClone.auditRefs); + expect(href).toContain('LCP=null'); + }); }); // This is done all in CSS, but tested here.