Skip to content

report: add label to provide context for subItems #13858

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
11 changes: 10 additions & 1 deletion lighthouse-core/audits/accessibility/axe-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ const i18n = require('../../lib/i18n/i18n.js');
const UIStrings = {
/** Label of a table column that identifies HTML elements that have failed an audit. */
failingElementsHeader: 'Failing Elements',
/** Label of a table column that identifies HTML elements that are related to a failure in an audit. */
relatedElementsHeader: 'Related Elements',
Copy link
Contributor

Choose a reason for hiding this comment

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

singular/plural for this is somewhat unfortunate. "Reasons" (when there's only one reason) seems worse to me than e.g. "Duplicate Elements" for some reason.

Could maybe make it the count an argument and only do a single option for cases that are always singular? I don't know if TC or whatever will complain/get weird with {relatedNodeCount, plural, other {Background Element}}, though.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
relatedElementsHeader: 'Related Elements',
relatedElementsHeader: 'Related elements',

Copy link
Collaborator Author

@connorjclark connorjclark Apr 15, 2022

Choose a reason for hiding this comment

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

yeah but Failed Elements :( change that too? it's the (regular) column text

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bump

};

const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);

class AxeAudit extends Audit {
static get relatedNodesLabel() {
Copy link
Contributor

Choose a reason for hiding this comment

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

static field or function instead of a getter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, this does match how we handle meta.

return str_(UIStrings.relatedElementsHeader);
}

/**
* Base class for audit rules which reflect assessment performed by the aXe accessibility library
* See https://github.com/dequelabs/axe-core/blob/6b444546cff492a62a70a74a8fc3c62bd4729400/doc/API.md#results-object for result type and format details
Expand Down Expand Up @@ -81,7 +87,10 @@ class AxeAudit extends Audit {
},
subItems: axeNode.relatedNodes.length ? {
type: 'subitems',
items: axeNode.relatedNodes.map(node => ({relatedNode: Audit.makeNodeItem(node)})),
label: this.relatedNodesLabel,
Copy link
Contributor

Choose a reason for hiding this comment

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

haha, this kind of thing makes me think axe-audit inheritance should just be killed and turned into a function call :)

items: axeNode.relatedNodes.map(node => ({
relatedNode: Audit.makeNodeItem(node),
})),
} : undefined,
}));
}
Expand Down
6 changes: 6 additions & 0 deletions lighthouse-core/audits/accessibility/color-contrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const UIStrings = {
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
description: 'Low-contrast text is difficult or impossible for many users to read. ' +
'[Learn more](https://web.dev/color-contrast/).',
/** Label of a table column that identifies a single HTML element that is the background of another HTML element. */
backgroundElementHeader: 'Background Element',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
backgroundElementHeader: 'Background Element',
backgroundElementHeader: 'Background element',

};

const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
Expand All @@ -40,6 +42,10 @@ class ColorContrast extends AxeAudit {
requiredArtifacts: ['Accessibility'],
};
}

static get relatedNodesLabel() {
return str_(UIStrings.backgroundElementHeader);
}
}

module.exports = ColorContrast;
Expand Down
6 changes: 6 additions & 0 deletions lighthouse-core/audits/accessibility/duplicate-id-aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const UIStrings = {
failureTitle: 'ARIA IDs are not unique',
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
description: 'The value of an ARIA ID must be unique to prevent other instances from being overlooked by assistive technologies. [Learn more](https://web.dev/duplicate-id-aria/).',
/** Label of a table column that identifies HTML elements that are duplicates of another HTML element. */
relatedElementsHeader: 'Duplicate Elements',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
relatedElementsHeader: 'Duplicate Elements',
relatedElementsHeader: 'Duplicate elements',

};

const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
Expand All @@ -37,6 +39,10 @@ class DuplicateIdAria extends AxeAudit {
requiredArtifacts: ['Accessibility'],
};
}

static get relatedNodesLabel() {
return str_(UIStrings.relatedElementsHeader);
}
}

module.exports = DuplicateIdAria;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
totalBytes: 0,
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.scriptResourceType),
items: subItems,
},
});
Expand All @@ -221,6 +222,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
totalBytes: 0,
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.scriptResourceType),
items: Array.from(overflowUrls).map(url => ({url})),
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ class LegacyJavascript extends ByteEfficiencyAudit {
url: script.url,
wastedBytes,
subItems: {
label: str_(i18n.UIStrings.columnLocation),
type: 'subitems',
items: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
const commonSourcePrefix = commonPrefix([...bundle.map.sourceInfos.keys()]);
item.subItems = {
type: 'subitems',
label: str_(i18n.UIStrings.module),
items: topUnusedSourceSizes.map(({source, unused, total}) => {
return {
source: trimCommonPrefix(source, commonSourcePrefix),
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/csp-xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class CspXss extends Audit {
},
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.reasons),
items,
},
});
Expand Down
4 changes: 4 additions & 0 deletions lighthouse-core/audits/dobetterweb/inspector-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class IssuesPanelEntries extends Audit {
issueType: 'Mixed content',
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.columnURL),
items: Array.from(requestUrls).map(url => ({url})),
},
};
Expand All @@ -86,6 +87,7 @@ class IssuesPanelEntries extends Audit {
issueType: 'Cookie',
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.columnURL),
items: Array.from(requestUrls).map(url => {
return {
url,
Expand All @@ -111,6 +113,7 @@ class IssuesPanelEntries extends Audit {
issueType: str_(UIStrings.issueTypeBlockedByResponse),
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.columnURL),
items: Array.from(requestUrls).map(url => {
return {
url,
Expand All @@ -136,6 +139,7 @@ class IssuesPanelEntries extends Audit {
issueType: 'Content security policy',
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.columnURL),
items: Array.from(requestUrls).map(url => {
return {
url,
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/non-composited-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class NonCompositedAnimations extends Audit {
node: Audit.makeNodeItem(element.node),
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.reasons),
items: allFailureReasons,
},
});
Expand Down
3 changes: 2 additions & 1 deletion lighthouse-core/audits/seo/hreflang.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

/** @typedef {string|LH.Audit.Details.NodeValue|undefined} Source */
/** @typedef {{source: Source, subItems: {type: 'subitems', items: SubItem[]}}} InvalidHreflang */
/** @typedef {{source: Source, subItems: {type: 'subitems', label: LH.IcuMessage, items: SubItem[]}}} InvalidHreflang */
/** @typedef {{reason: LH.IcuMessage}} SubItem */

const Audit = require('../audit.js');
Expand Down Expand Up @@ -120,6 +120,7 @@ class Hreflang extends Audit {
source,
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.reasons),
items: reasons.map(reason => ({reason})),
},
});
Expand Down
6 changes: 5 additions & 1 deletion lighthouse-core/audits/third-party-facades.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ class ThirdPartyFacades extends Audit {
product: productWithCategory,
transferSize: entitySummary.transferSize,
blockingTime: entitySummary.blockingTime,
subItems: {type: 'subitems', items},
subItems: {
type: 'subitems',
label: str_(i18n.UIStrings.scriptResourceType),
items,
},
});
}

Expand Down
4 changes: 4 additions & 0 deletions lighthouse-core/lib/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ const UIStrings = {
thirdPartyResourceType: 'Third-party',
/** Label used to identify a value in a table where many individual values are aggregated to a single value, for brevity. "Other resources" could also be read as "the rest of the resources". Resource refers to network resources requested by the browser. */
otherResourcesLabel: 'Other resources',
/** Label for a row in a data table; 'Module' refers to a JavaScript module file. */
module: 'Module',
/** Label for a row in a data table; What follows are reasons why something failed or occurred. */
reasons: 'Reasons',
/** The name of the metric that marks the time at which the first text or image is painted by the browser. Shown to users as the label for the numeric metric value. Ideally fits within a ~40 character limit. */
firstContentfulPaintMetric: 'First Contentful Paint',
/** The name of the metric that marks the time at which the page is fully loaded and is able to quickly respond to user input (clicks, taps, and keypresses feel responsive). Shown to users as the label for the numeric metric value. Ideally fits within a ~40 character limit. */
Expand Down
Loading