-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: refactor rendering of top-level failed/passing/etc sections #6460
Conversation
also, we can pick a different name than "top-level section". I couldn't think of one (and overloading "group" seems like a mistake in retrospect :) |
.querySelector('.lh-audit-group--manual .lh-audit-group__description').textContent; | ||
// may need to be adjusted if description includes a link at the beginning | ||
assert.ok(description.startsWith(pwaCategory.manualDescription.substring(0, 20)), | ||
'no manual description'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we weren't asserting that there was a manual description in the report before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so great. way cleaner.
*/ | ||
_getTotalAuditsLength(elements) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so happy you managed to nuke this. 🙌
auditGroupElem.appendChild(this.renderAudit(audit, i)); | ||
}); | ||
return auditGroupElem; | ||
renderTopLevelSection(sectionId, auditRefs, groupDefinitions, description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderCategorySection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe a little ascii diagram of what accessibility section looks like wrt groups & clumps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and done
element.appendChild(manualEl); | ||
} | ||
// Render each section. | ||
for (const [sectionIdStr, sectionRefs] of Object.entries(sections)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're relying on order of Object.entries(), right? is that safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're relying on order of Object.entries(), right? is that safe?
well, there's safe and then there's safe :)
switched to a Map
const expandable = true; | ||
const elements = this._renderGroupedAudits(auditRefs, groupDefinitions, {expandable}); | ||
|
||
const sectionInfo = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this outside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this outside?
done
/** | ||
* Display info per top-level clump. Define on class to avoid race with Util init. | ||
*/ | ||
get _clumpInfo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of annoyingly this has to be defined on the class so that Util
is available (not a problem in regular use, but Util isn't globally defined yet when this file is required in tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a name that a certain someone would complain conveys no information 😉
_clumpDisplayClasses
_clumpDisplayAttributes
_clumpDisplayInfo
at least?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a name that a certain someone would complain conveys no information
lulz I'm always in favor of more descriptive names. Switching to _clumpDisplayInfo
though I can switch it more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so great. love it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
are we really going to go with "clump" though? 😆 #smooshgatev2
/** | ||
* Display info per top-level clump. Define on class to avoid race with Util init. | ||
*/ | ||
get _clumpInfo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a name that a certain someone would complain conveys no information 😉
_clumpDisplayClasses
_clumpDisplayAttributes
_clumpDisplayInfo
at least?
const grouped = new Map(); | ||
|
||
// Add audits without a group first so they will appear first. | ||
const notAGroup = 'NotAGroup'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
* @param {LH.ReportResult.AuditRef} auditRef | ||
* @return {TopLevelClumpId} | ||
*/ | ||
_getClumpIdForAuditRef(auditRef) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this fn!
auditGroupElem.appendChild(this.renderAudit(audit, i)); | ||
}); | ||
return auditGroupElem; | ||
renderClump(clumpId, auditRefs, groupDefinitions, description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this feels a bit many arguments to remember what all the args are for in order, time for an object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time for an object?
done
haha, well, @paulirish really didn't like my suggestions, and we couldn't keep calling them groups because that was confusing with the other (config) groups... So we looked at a thesaurus and that one was sufficiently funny. Maybe a name will more naturally come out later. |
This makes the process of grouping under failed/passing/manual/notApplicable and then again under audit groups a lot easier to understand. It also sets the stage for making a new
pwa-category-renderer.js
(where they aren't split into failed/passing/etc) much easier.Before the renderer was mixing up levels of failed/passing/notApplicable and audit groups, putting those states inside groups, then ending up rendering the opposite way (groups inside failed/passing/notApplicable). Manual audits were handled separately, even though it's just another of these states.
Instead, this new code sorts by state, then renders groups in each of them. The code is just a little shorter (longer with new tests), but it's hopefully easier to follow.
Importantly, this makes for an easy interface for
renderTopLevelSection
(whichperformance-category-renderer
now uses) andrenderUnexpandableTopLevelSection
(which the pwa one will use).It also lets us get rid of
_getTotalAuditsLength
and allows easy numbering across groups now.The numbering is the only thing that has changed from master (so no changed tests, only new ones). edit: also (collapsed) passed audits in the performance section are now grouped like they are in other categories