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: score of 1 for informative audits #15689

Merged
merged 8 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
12 changes: 6 additions & 6 deletions cli/test/smokehouse/test-definitions/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ const expectations = {
},
},
'duplicate-id-aria': {
score: null,
score: 1,
details: {
items: [
{
Expand Down Expand Up @@ -515,7 +515,7 @@ const expectations = {
},
},
'empty-heading': {
score: null,
score: 1,
details: {
items: [
{
Expand All @@ -531,7 +531,7 @@ const expectations = {
},
},
'form-field-multiple-labels': {
score: null,
score: 1,
scoreDisplayMode: 'informative',
details: {
items: [
Expand Down Expand Up @@ -625,7 +625,7 @@ const expectations = {
scoreDisplayMode: 'notApplicable',
},
'identical-links-same-purpose': {
score: null,
score: 1,
details: {
items: [
{
Expand Down Expand Up @@ -739,7 +739,7 @@ const expectations = {
},
},
'landmark-one-main': {
score: null,
score: 1,
details: {
items: [
{
Expand Down Expand Up @@ -931,7 +931,7 @@ const expectations = {
},
},
'target-size': {
score: null,
score: 1,
details: {
items: [
{
Expand Down
2 changes: 1 addition & 1 deletion cli/test/smokehouse/test-definitions/dobetterweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ const expectations = {
},
},
'dom-size': {
score: null,
score: 1,
numericValue: 154,
details: {
items: [
Expand Down
4 changes: 2 additions & 2 deletions cli/test/smokehouse/test-definitions/perf-budgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const expectations = {
finalDisplayedUrl: 'http://localhost:10200/perf/perf-budgets/load-things.html',
audits: {
'resource-summary': {
score: null,
score: 1,
details: {
items: [
{resourceType: 'total', requestCount: 10, transferSize: '166472±1000'},
Expand All @@ -83,7 +83,7 @@ const expectations = {
},
},
'performance-budget': {
score: null,
score: 1,
details: {
// Undefined items are asserting that the property isn't included in the table item.
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const expectations = {
finalDisplayedUrl: 'http://localhost:10200/perf/animations.html',
audits: {
'non-composited-animations': {
score: null,
score: 1,
displayValue: '1 animated element found',
details: {
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const expectations = {
finalDisplayedUrl: 'http://localhost:10200/perf/frame-metrics.html',
audits: {
'metrics': {
score: null,
score: 1,
details: {
type: 'debugdata',
items: [
Expand Down
4 changes: 2 additions & 2 deletions cli/test/smokehouse/test-definitions/perf-trace-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const expectations = {
},
},
'layout-shift-elements': {
score: null,
score: 1,
displayValue: '2 elements found',
details: {
items: [
Expand Down Expand Up @@ -228,7 +228,7 @@ const expectations = {
},
},
'long-tasks': {
score: null,
score: 1,
details: {
items: {
0: {
Expand Down
4 changes: 4 additions & 0 deletions core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ class Audit {
* @return {number|null}
*/
static _normalizeAuditScore(score, scoreDisplayMode, auditId) {
if (scoreDisplayMode === Audit.SCORING_MODES.INFORMATIVE) {
return 1;
}

if (scoreDisplayMode !== Audit.SCORING_MODES.BINARY &&
scoreDisplayMode !== Audit.SCORING_MODES.NUMERIC &&
scoreDisplayMode !== Audit.SCORING_MODES.METRIC_SAVINGS) {
Expand Down
4 changes: 4 additions & 0 deletions core/lib/lighthouse-compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function upgradeLhrForCompatibility(lhr) {
audit.scoreDisplayMode = 'notApplicable';
}

if (audit.scoreDisplayMode === 'informative') {
audit.score = 1;
}

if (audit.details) {
// Turn `auditDetails.type` of undefined (LHR <4.2) and 'diagnostic' (LHR <5.0)
// into 'debugdata' (LHR ≥5.0).
Expand Down
6 changes: 3 additions & 3 deletions core/test/audits/audit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ describe('Audit', () => {
assert.strictEqual(auditResult.score, 1);
});

it('override scoreDisplayMode if set on audit product', () => {
it('switches to INFORMATIVE and set score to 1 if set on audit product', () => {
assert.strictEqual(NumericAudit.meta.scoreDisplayMode, Audit.SCORING_MODES.NUMERIC);
const auditResult = Audit.generateAuditResult(NumericAudit, {
score: 1,
score: null,
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
});
assert.strictEqual(auditResult.scoreDisplayMode, Audit.SCORING_MODES.INFORMATIVE);
assert.strictEqual(auditResult.score, null);
assert.strictEqual(auditResult.score, 1);
});

it('switches to an ERROR and is not scored if an errorMessage is passed in', () => {
Expand Down
Loading
Loading