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: require score in audit product; make rawValue numeric only #8343

Merged
merged 2 commits into from
Apr 17, 2019

Conversation

brendankenny
Copy link
Member

The majority of the change in #6199 (comment).

  • makes score a required part of LH.Audit.Product, either a number or null (in case of ERROR, NOT_APPLICABLE, or INFORMATIVE)
  • make all boolean uses of rawValue into a score of 0 or 1, then drop those rawValues

Mostly string replace, except in audit.js and audit-test.js

after this I think we want to (at least) rename rawValue to finish out #6199

@patrickhulce
Copy link
Collaborator

patrickhulce commented Apr 16, 2019

Mostly string replace, except in audit.js and audit-test.js

Only done a quick scan, but it's fair to say those two files are the only meat right?

@brendankenny
Copy link
Member Author

Only done a quick scan, but it's fair to say those two files are the only meat right?

yeah, tap-targets-test.js needed some rounding due to the scoring used in that audit and there are the limited type/comment changes in audit.d.ts, but the rest are all trivial replacements. Even sample_v2.json only had "rawValue": (true|false) lines removed, and thanks to @hoten's work in #7780, smoke expectations didn't change at all (all remaining rawValues in those are numeric)

@@ -389,7 +390,7 @@ describe('Runner', () => {
return Runner.run({}, {config}).then(results => {
const audits = results.lhr.audits;
assert.equal(audits['critical-request-chains'].displayValue, '5 chains found');
assert.equal(audits['critical-request-chains'].rawValue, false);
assert.equal(audits['critical-request-chains'].details.longestChain.transferSize, 2468);
Copy link
Member Author

Choose a reason for hiding this comment

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

oh, I guess not quite string replace in this file because it made no sense to assert the score on these. They're all null since the audit is INFORMATIVE

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM! rename those strings 🖊

return {
id: 'numeric-time',
title: 'Numbersssss',
description: '01000000001011011111100001010100',
Copy link
Collaborator

Choose a reason for hiding this comment

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

@-�T?

c'mon gotta have some next level messaging in here :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

01101101011001010110111101110111

Copy link
Member Author

Choose a reason for hiding this comment

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

not everything's a character :P

new Float32Array(new Uint32Array([0b01000000001011011111100001010100]).buffer)[0]

Copy link
Collaborator

Choose a reason for hiding this comment

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

touche :)

const auditResult = Audit.generateAuditResult(PassOrFailAudit,
{score: 0, errorMessage: 'what errors lurk'});
assert.strictEqual(auditResult.score, null);
assert.equal(auditResult.title, 'Passing');
Copy link
Collaborator

Choose a reason for hiding this comment

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

we use the passing title for errors? funny the things you learn in testing :)

Copy link
Member Author

Choose a reason for hiding this comment

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

we use the passing title for errors? funny the things you learn in testing :)

yeah, I was really surprised when I made score === null explicitly use the failureTitle and a whole bunch of things changed in sample_v2.json :)

I'm not entirely convinced it was on purpose, but it makes sense for NOT_APPLICABLE and INFORMATIVE, and it kind of makes sense for ERROR, since we don't know the page was doing the failure thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants