Skip to content

Commit

Permalink
core(redirects): score only on wasted ms (#15401)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Aug 23, 2023
1 parent cd09b63 commit 614170f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const expectations = {
numericValue: '>=2000',
},
'redirects': {
score: 1,
score: 0.29,
numericValue: '>=2000',
details: {
items: [
Expand Down
5 changes: 1 addition & 4 deletions core/audits/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ class Redirects extends Audit {
{overallSavingsMs: totalWastedMs});

return {
// We award a passing grade if you only have 1 redirect
// TODO(phulce): reconsider if cases like the example in https://github.com/GoogleChrome/lighthouse/issues/8984
// should fail this audit.
score: documentRequests.length <= 2 ? 1 : ByteEfficiencyAudit.scoreForWastedMs(totalWastedMs),
score: ByteEfficiencyAudit.scoreForWastedMs(totalWastedMs),
numericValue: totalWastedMs,
numericUnit: 'millisecond',
displayValue: totalWastedMs ?
Expand Down
6 changes: 2 additions & 4 deletions core/test/audits/redirects-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,12 @@ describe('Performance: Redirects audit', () => {
});
});

it('passes when one redirect detected', () => {
it('fails when 1 redirect detected', () => {
const artifacts = mockArtifacts(SUCCESS_ONE_REDIRECT, 'https://www.lisairish.com/');
const context = {settings: {}, computedCache: new Map()};
return RedirectsAudit.audit(artifacts, context).then(output => {
// If === 1 redirect, perfect score is expected, regardless of latency
// We will still generate a table and show wasted time
expect(output.details.items).toHaveLength(2);
expect(output.score).toEqual(1);
expect(output.score).toEqual(0.48);
expect(output.numericValue).toMatchInlineSnapshot(`1000`);
expect(output.metricSavings).toEqual({LCP: 1000, FCP: 1000});
});
Expand Down

0 comments on commit 614170f

Please sign in to comment.