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: New audit clump for audits with warnings (#5327) #6989

Merged
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
4 changes: 4 additions & 0 deletions lighthouse-core/lib/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,10 @@
"message": "Values are estimated and may vary.",
"description": "Disclaimer shown to users below the metric values (First Contentful Paint, Time to Interactive, etc) to warn them that the numbers they see will likely change slightly the next time they run Lighthouse."
},
"lighthouse-core/report/html/renderer/util.js | warningAuditsGroupTitle": {
"message": "Audits with warnings",
"description": "Section heading shown above a list of audits that contain warnings."
},
"lighthouse-core/report/html/renderer/util.js | warningHeader": {
"message": "Warnings: ",
"description": "This label is shown above a bulleted list of warnings. It is shown directly below an audit that produced warnings. Warnings describe situations the user should be aware of, as Lighthouse was unable to complete all the work required on this audit. For example, The 'Unable to decode image (biglogo.jpg)' warning may show up below an image encoding audit."
Expand Down
20 changes: 18 additions & 2 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'|'notApplicable'} TopLevelClumpId */
/** @typedef {'failed'|'warning'|'manual'|'passed'|'notApplicable'} TopLevelClumpId */

class CategoryRenderer {
/**
Expand All @@ -45,6 +45,7 @@ class CategoryRenderer {
*/
get _clumpTitles() {
return {
warning: Util.UIStrings.warningAuditsGroupTitle,
Copy link
Member

Choose a reason for hiding this comment

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

it's unfortunate we used "group" for these :/

manual: Util.UIStrings.manualAuditsGroupTitle,
passed: Util.UIStrings.passedAuditsGroupTitle,
notApplicable: Util.UIStrings.notApplicableAuditsGroupTitle,
Expand Down Expand Up @@ -264,6 +265,10 @@ class CategoryRenderer {
const clumpTmpl = this.dom.cloneTemplate('#tmpl-lh-clump', this.templateContext);
const clumpElement = this.dom.find('.lh-clump', clumpTmpl);

if (clumpId === 'warning') {
Copy link
Member

Choose a reason for hiding this comment

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

do we want it to be an open <details> or do we want it to be like failed audits and use renderUnexpandableClump? It seems like it should maybe operate like failed, but I'm not sure how others feel on this point.

Copy link
Member

Choose a reason for hiding this comment

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

renderUnexpandableClump's don't have titles/descriptions so .... let's stick with this approach.
(If it supported titles, I would have said we do that.)

clumpElement.setAttribute('open', '');
}

const summaryInnerEl = this.dom.find('.lh-audit-group__summary', clumpElement);
const chevronEl = summaryInnerEl.appendChild(this._createChevron());
chevronEl.title = Util.UIStrings.auditGroupExpandTooltip;
Expand Down Expand Up @@ -333,6 +338,14 @@ class CategoryRenderer {
return tmpl;
}

/**
* @param {LH.ReportResult.AuditRef} audit
* @return {boolean}
*/
_auditHasWarning(audit) {
return Boolean(audit.result.warnings && audit.result.warnings.length);
}

/**
* Returns the id of the top-level clump to put this audit in.
* @param {LH.ReportResult.AuditRef} auditRef
Expand All @@ -344,7 +357,9 @@ class CategoryRenderer {
return scoreDisplayMode;
}

if (Util.showAsPassed(auditRef.result)) {
if (this._auditHasWarning(auditRef)) {
return 'warning';
} else if (Util.showAsPassed(auditRef.result)) {
Copy link
Member

Choose a reason for hiding this comment

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

hmm, we should figure out what we want the priority order to be here. Does warning win over failed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to require a passing state for all warnings.

return 'passed';
} else {
return 'failed';
Expand Down Expand Up @@ -382,6 +397,7 @@ class CategoryRenderer {
/** @type {Map<TopLevelClumpId, Array<LH.ReportResult.AuditRef>>} */
const clumps = new Map();
clumps.set('failed', []);
clumps.set('warning', []);
Copy link
Member

Choose a reason for hiding this comment

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

should add 'warning' to the list of statuses in the method jsdoc for render() above

clumps.set('manual', []);
clumps.set('passed', []);
clumps.set('notApplicable', []);
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ Util.UIStrings = {
warningHeader: 'Warnings: ',
/** The tooltip text on an expandable chevron icon. Clicking the icon expands a section to reveal a list of audit results that was hidden by default. */
auditGroupExpandTooltip: 'Show audits',
/** Section heading shown above a list of audits that contain warnings. */
Copy link
Member

Choose a reason for hiding this comment

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

Need some context for "warnings" for the translators ("contain warnings" is pretty ambiguous in isolation)...what they are, how they're used sort of thing. See below for examples.

warningAuditsGroupTitle: 'Audits with warnings',
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we should be more specific with something like Passed audits with warnings. And is "with warnings" how we want to phrase it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wb Passed but contains (or with) warnings? the manual and the n/a titles don't explicitly say "audit".

/** Section heading shown above a list of audits that are passing. 'Passed' here refers to a passing grade. This section is collapsed by default, as the user should be focusing on the failed audits instead. Users can click this heading to reveal the list. */
passedAuditsGroupTitle: 'Passed audits',
/** Section heading shown above a list of audits that do not apply to the page. For example, if an audit is 'Are images optimized?', but the page has no images on it, the audit will be marked as not applicable. This is neither passing or failing. This section is collapsed by default, as the user should be focusing on the failed audits instead. Users can click this heading to reveal the list. */
Expand Down
4 changes: 4 additions & 0 deletions lighthouse-core/report/html/report-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
vertical-align: middle;
}

.lh-clump--warning > summary .lh-audit-group__header::before {
content: '';
background-image: var(--search-icon-url);
}
.lh-clump--manual > summary .lh-audit-group__header::before {
content: '';
background-image: var(--search-icon-url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ describe('CategoryRenderer', () => {
assert.ok(warningEl.textContent.includes(auditResult.warnings[1]), '2nd warning provided');
});

it('expands warning audit group', () => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: move this under the clumping describe() since it's really about the clump correctly working

const category = sampleResults.reportCategories.find(c => c.id === 'pwa');
const categoryClone = JSON.parse(JSON.stringify(category));
categoryClone.auditRefs[0].result.warnings = ['Some warning'];

const auditDOM = renderer.render(categoryClone, sampleResults.categoryGroups);
const warningClumpEl = auditDOM.querySelector('.lh-clump--warning');
const isExpanded = warningClumpEl.hasAttribute('open');
assert.ok(isExpanded, 'Warning audit group should be expanded by default');
});

it('renders a category', () => {
const category = sampleResults.reportCategories.find(c => c.id === 'pwa');
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
Expand Down Expand Up @@ -314,16 +325,18 @@ describe('CategoryRenderer', () => {
});
});

describe('clumping passed/failed/manual', () => {
describe('clumping passed/failed/warning/manual', () => {
brendankenny marked this conversation as resolved.
Show resolved Hide resolved
it('separates audits in the DOM', () => {
const category = sampleResults.reportCategories.find(c => c.id === 'pwa');
const elem = renderer.render(category, sampleResults.categoryGroups);
const passedAudits = elem.querySelectorAll('.lh-clump--passed .lh-audit');
const failedAudits = elem.querySelectorAll('.lh-clump--failed .lh-audit');
const warningAudits = elem.querySelectorAll('.lh-clump--warning .lh-audit');
const manualAudits = elem.querySelectorAll('.lh-clump--manual .lh-audit');

assert.equal(passedAudits.length, 4);
assert.equal(failedAudits.length, 8);
assert.equal(warningAudits.length, 0);
Copy link
Member

Choose a reason for hiding this comment

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

this test doesn't end up testing much :) WDYT about adding a warning to one of the passed audits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are no passing audits with warnings in the sample json, and I'm not sure how to update the source appropriately. fine to just manually set some warnings in the test case?

Copy link
Member

Choose a reason for hiding this comment

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

fine to just manually set some warnings in the test case

perfect

assert.equal(manualAudits.length, 3);
});

Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4343,6 +4343,7 @@
"scorescaleLabel": "Score scale:",
"toplevelWarningsMessage": "There were issues affecting this run of Lighthouse:",
"varianceDisclaimer": "Values are estimated and may vary.",
"warningAuditsGroupTitle": "Audits with warnings",
"warningHeader": "Warnings: "
},
"icuMessagePaths": {
Expand Down
3 changes: 3 additions & 0 deletions proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ message I18n {

// The title of the lab data performance category
string lab_data_title = 16;

// The heading that is shown above a list of audits that have warnings
string warning_audits_group_title = 17;
}

// The message holding all formatted strings
Expand Down
1 change: 1 addition & 0 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,7 @@
"scorescaleLabel": "Score scale:",
"toplevelWarningsMessage": "There were issues affecting this run of Lighthouse:",
"varianceDisclaimer": "Values are estimated and may vary.",
"warningAuditsGroupTitle": "Audits with warnings",
"warningHeader": "Warnings: "
}
},
Expand Down