Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(redirects): score only on wasted ms #15401

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading