Skip to content

Commit

Permalink
report: handle non-numeric numericValues in calc link (#10880)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored Apr 25, 2022
1 parent 87310f2 commit d486855
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion report/test/renderer/performance-category-renderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,24 @@ 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;
lcp.result.score = null;
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.
Expand Down

0 comments on commit d486855

Please sign in to comment.