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: change 'not-applicable' to 'notApplicable' #6783

Merged
merged 9 commits into from
Jan 5, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ module.exports = [
score: 1,
},
'user-timings': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'critical-request-chains': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'installable-manifest': {
score: 0,
Expand All @@ -75,22 +75,22 @@ module.exports = [
score: 0,
},
'aria-valid-attr': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'aria-allowed-attr': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'color-contrast': {
score: 1,
},
'image-alt': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'label': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'tabindex': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'content-width': {
score: 1,
Expand Down Expand Up @@ -121,10 +121,10 @@ module.exports = [
score: 1,
},
'user-timings': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'critical-request-chains': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'installable-manifest': {
score: 1,
Expand All @@ -136,10 +136,10 @@ module.exports = [
score: 0,
},
'aria-valid-attr': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'aria-allowed-attr': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'color-contrast': {
score: 1,
Expand All @@ -148,10 +148,10 @@ module.exports = [
score: 0,
},
'label': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'tabindex': {
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
'content-width': {
score: 1,
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/seo/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = [
},
'robots-txt': {
rawValue: true,
scoreDisplayMode: 'not-applicable',
scoreDisplayMode: 'notApplicable',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Audit {
BINARY: 'binary',
MANUAL: 'manual',
INFORMATIVE: 'informative',
NOT_APPLICABLE: 'not-applicable',
NOT_APPLICABLE: 'notApplicable',
ERROR: 'error',
};
}
Expand Down
8 changes: 6 additions & 2 deletions lighthouse-core/lib/proto-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ function processForProto(result) {

// Rewrite the 'not-applicable' scoreDisplayMode to 'not_applicable'. #6201
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
if (audit.scoreDisplayMode) {
if (audit.scoreDisplayMode === 'not-applicable') {
// @ts-ignore ts properly flags this as invalid as it should not happen,
// but remains in preprocessor to protect from proto translation errors from
// old LHRs.
// eslint-disable-next-line max-len
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
if (audit.scoreDisplayMode === 'not-applicable' || audit.scoreDisplayMode === 'not_applicable') {
// @ts-ignore Breaking the LH.Result type
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
audit.scoreDisplayMode = 'not_applicable';
audit.scoreDisplayMode = 'notApplicable';
}
}
// Drop raw values. #6199
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/report/html/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/** @typedef {import('./report-renderer.js')} ReportRenderer */
/** @typedef {import('./details-renderer.js')} DetailsRenderer */
/** @typedef {import('./util.js')} Util */
/** @typedef {'failed'|'manual'|'passed'|'not-applicable'} TopLevelClumpId */
/** @typedef {'failed'|'manual'|'passed'|'notApplicable'} TopLevelClumpId */
exterkamp marked this conversation as resolved.
Show resolved Hide resolved

class CategoryRenderer {
/**
Expand Down Expand Up @@ -56,7 +56,7 @@ class CategoryRenderer {
title: Util.UIStrings.passedAuditsGroupTitle,
className: 'lh-clump--passed',
},
'not-applicable': {
'notApplicable': {
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
title: Util.UIStrings.notApplicableAuditsGroupTitle,
className: 'lh-clump--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.

need to update

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh we should get a puppeteer screenshot test in for the report to catch these css mismatches

Copy link
Member

Choose a reason for hiding this comment

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

oh we should get a puppeteer screenshot test in for the report to catch these css mismatches

good idea. Don't we also have a jsdom test or two looking for the not applicable results? Concerning they weren't found...

Copy link
Member

Choose a reason for hiding this comment

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

Concerning they weren't found...

oh, because the test selectors weren't updated either :)

But now I'm questioning if it should be updated :) We don't currently create the clump names dynamically, so it can be whatever we want. Commonly notApplicable in js goes to not-applicable in css, but do we care? Or is notapplicable fine? Keeping camelCase seems gross, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would go for not-applicable makes it easier to read in my opinion

},
Expand Down Expand Up @@ -370,7 +370,7 @@ class CategoryRenderer {
*/
_getClumpIdForAuditRef(auditRef) {
const scoreDisplayMode = auditRef.result.scoreDisplayMode;
if (scoreDisplayMode === 'manual' || scoreDisplayMode === 'not-applicable') {
if (scoreDisplayMode === 'manual' || scoreDisplayMode === 'notApplicable') {
return scoreDisplayMode;
}

Expand All @@ -397,7 +397,7 @@ class CategoryRenderer {
clumps.set('failed', []);
clumps.set('manual', []);
clumps.set('passed', []);
clumps.set('not-applicable', []);
clumps.set('notApplicable', []);

// Sort audits into clumps.
for (const auditRef of category.auditRefs) {
Expand Down
8 changes: 5 additions & 3 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class Util {
// The proto process turns 'not-applicable' into 'not_applicable'. Correct this to support both.
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
// TODO: remove when underscore/hyphen proto issue is resolved. See #6371, #6201.
for (const audit of Object.values(clone.audits)) {
// TODO(exterkamp): remove this when proto enum removes 'not_applicable'
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore tsc rightly flags that this value shouldn't occur.
if (audit.scoreDisplayMode === 'not_applicable') {
audit.scoreDisplayMode = 'not-applicable';
// eslint-disable-next-line max-len
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
if (audit.scoreDisplayMode === 'not_applicable' || audit.scoreDisplayMode === 'not-applicable') {
audit.scoreDisplayMode = 'notApplicable';
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -163,7 +165,7 @@ class Util {
*/
static calculateRating(score, scoreDisplayMode) {
// Handle edge cases first, manual and not applicable receive 'pass', errored audits receive 'error'
if (scoreDisplayMode === 'manual' || scoreDisplayMode === 'not-applicable') {
if (scoreDisplayMode === 'manual' || scoreDisplayMode === 'notApplicable') {
return RATINGS.PASS.label;
} else if (scoreDisplayMode === 'error') {
return RATINGS.ERROR.label;
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/audits/audit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Audit', () => {
const providedResult = {rawValue: true, notApplicable: true};
const result = Audit.generateAuditResult(B, providedResult);
assert.equal(result.score, null);
assert.equal(result.scoreDisplayMode, 'not-applicable');
assert.equal(result.scoreDisplayMode, 'notApplicable');
});

it('sets state of failed audits', () => {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/lib/proto-preprocessor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('processing for proto', () => {
const expectation = {
'audits': {
'critical-request-chains': {
'scoreDisplayMode': 'not_applicable',
'scoreDisplayMode': 'notApplicable',
'displayValue': 'hello %d | 123',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('CategoryRenderer', () => {
'.lh-clump--not-applicable .lh-audit-group__summary'));

const notApplicableCount = a11yCategory.auditRefs.reduce((sum, audit) =>
sum += audit.result.scoreDisplayMode === 'not-applicable' ? 1 : 0, 0);
sum += audit.result.scoreDisplayMode === 'notApplicable' ? 1 : 0, 0);
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
assert.equal(
categoryDOM.querySelectorAll('.lh-clump--not-applicable .lh-audit').length,
notApplicableCount,
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('CategoryRenderer', () => {
it.skip('renders the failed audits grouped by group', () => {
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
const failedAudits = category.auditRefs.filter(audit => {
return audit.result.score !== 1 && !audit.result.scoreDisplayMode === 'not-applicable';
return audit.result.score !== 1 && !audit.result.scoreDisplayMode === 'notApplicable';
});
const failedAuditTags = new Set(failedAudits.map(audit => audit.group));

Expand All @@ -213,7 +213,7 @@ describe('CategoryRenderer', () => {
it('renders the passed audits grouped by group', () => {
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
const passedAudits = category.auditRefs.filter(audit =>
audit.result.scoreDisplayMode !== 'not-applicable' && audit.result.score === 1);
audit.result.scoreDisplayMode !== 'notApplicable' && audit.result.score === 1);
const passedAuditTags = new Set(passedAudits.map(audit => audit.group));

const passedAuditGroups = categoryDOM.querySelectorAll('.lh-clump--passed .lh-audit-group');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('ReportRenderer', () => {

let notApplicableCount = 0;
Object.values(clonedSampleResult.audits).forEach(audit => {
if (audit.scoreDisplayMode === 'not-applicable') {
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
if (audit.scoreDisplayMode === 'notApplicable') {
notApplicableCount++;
audit.scoreDisplayMode = 'not_applicable';
}
Expand All @@ -196,8 +196,7 @@ describe('ReportRenderer', () => {
const container = renderer._dom._document.body;
const reportElement = renderer.renderReport(sampleResults, container);
const notApplicableElementCount = reportElement
.querySelectorAll('.lh-audit--not-applicable').length;

.querySelectorAll('.lh-audit--notApplicable').length;
assert.strictEqual(notApplicableCount, notApplicableElementCount);
});
});
4 changes: 2 additions & 2 deletions lighthouse-core/test/report/html/renderer/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ describe('util helpers', () => {
});

describe('#prepareReportResult', () => {
it('corrects underscored `not-applicable` scoreDisplayMode', () => {
it('corrects underscored `notApplicable` scoreDisplayMode', () => {
const clonedSampleResult = JSON.parse(JSON.stringify(sampleResult));

let notApplicableCount = 0;
Object.values(clonedSampleResult.audits).forEach(audit => {
if (audit.scoreDisplayMode === 'not-applicable') {
if (audit.scoreDisplayMode === 'notApplicable') {
notApplicableCount++;
audit.scoreDisplayMode = 'not_applicable';
}
Expand Down
Loading