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

report(util): ✅ audits should be in Passed Audits #5963

Merged
merged 4 commits into from
Sep 8, 2018
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 lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ class Util {
case 'numeric':
case 'binary':
default:
// Numeric audits that are within PASS_THRESHOLD will still show up with failing.
// For opportunities, we want to have them show up with other failing for contrast.
// For diagnostics, we sort by score so they'll be lowest priority.
return Number(audit.score) === 1;
return Number(audit.score) >= RATINGS.PASS.minScore;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const sampleResultsOrig = require('../../../results/sample_v2.json');
const TEMPLATE_FILE = fs.readFileSync(__dirname +
'/../../../../report/html/templates.html', 'utf8');

const PASS_THRESHOLD = 0.9;

describe('PerfCategoryRenderer', () => {
let category;
let renderer;
Expand Down Expand Up @@ -140,7 +142,7 @@ describe('PerfCategoryRenderer', () => {
const diagnosticSection = categoryDOM.querySelectorAll('.lh-category > .lh-audit-group')[2];

const diagnosticAudits = category.auditRefs.filter(audit => audit.group === 'diagnostics' &&
audit.result.score !== 1 && audit.result.scoreDisplayMode !== 'not-applicable');
audit.result.score < PASS_THRESHOLD && audit.result.scoreDisplayMode !== 'not-applicable');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just use Util.PASS_THRESHOLD instead of the local declaration above.

i think that'll be fine despite all the jsdom beforeEach bs. but holler if its stupid.

const diagnosticElements = diagnosticSection.querySelectorAll('.lh-audit');
assert.equal(diagnosticElements.length, diagnosticAudits.length);
});
Expand All @@ -151,7 +153,8 @@ describe('PerfCategoryRenderer', () => {

const passedAudits = category.auditRefs.filter(audit =>
audit.group && audit.group !== 'metrics' &&
(audit.result.score === 1 || audit.result.scoreDisplayMode === 'not-applicable'));
(audit.result.score >= PASS_THRESHOLD ||
audit.result.scoreDisplayMode === 'not-applicable'));
const passedElements = passedSection.querySelectorAll('.lh-audit');
assert.equal(passedElements.length, passedAudits.length);
});
Expand Down