-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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: reuse generalized clumping for perf category #9288
Conversation
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.
LGTM!
@@ -68,7 +68,17 @@ describe('PerfCategoryRenderer', () => { | |||
it('renders the sections', () => { | |||
const categoryDOM = renderer.render(category, sampleResults.categoryGroups); | |||
const sections = categoryDOM.querySelectorAll('.lh-category > .lh-audit-group'); | |||
assert.equal(sections.length, 5); | |||
const sectionTitles = Array.from(sections).map(el => el.className); | |||
expect(sectionTitles).toMatchInlineSnapshot(` |
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.
😍
const passedAudits = category.auditRefs.filter(audit => | ||
audit.group && audit.group !== 'metrics' && audit.id !== 'performance-budget' | ||
&& Util.showAsPassed(audit.result)); | ||
const passedAudits = category.auditRefs.filter( |
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.
rename to passedAuditIds
?
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.
seems good to share the implementation
I noticed that perf audits with warnings don't use the Passed audits but with warnings clump that @connorjclark added in #6989.
can you add a test that those do get rendered with a warning now?
@@ -156,7 +156,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer { | |||
|
|||
// Filmstrip | |||
const timelineEl = this.dom.createChildOf(element, 'div', 'lh-filmstrip-container'); | |||
const thumbnailAudit = category.auditRefs.find(audit => audit.id === 'screenshot-thumbnails'); | |||
const thumbnailAudit = category.auditRefs.find(audit => audit.group === 'filmstrip'); |
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 doesn't seem better since (here and below) the code really is looking for a particular audit, not whatever happens to be first in a group (or happens to be the only one in a group)?
const renderedAudits = [...metricAudits, thumbnailAudit, budgetAudit, ...opportunityAudits, | ||
...diagnosticAudits]; | ||
const unrenderedAudits = category.auditRefs.filter(ref => !renderedAudits.includes(ref)); | ||
const remainingAudits = unrenderedAudits.filter(ref => !!ref.group); |
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 seems like it'll be easy to forget to add things to the renderedAudits
list and get them rendered twice.
What if we switched how we do the non-rendered audits and gave them an explicit group (report-invisible
or a name equally as good) instead of no group?
It would reduce the mystery of how the audits that don't show up in the html report work and let this check just be whatever hasn't been rendered yet and isn't in that group.
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 sounds good.
it means every auditRef needs a group. but that works for me.
the tricky thing is manual
audits are currently defined by their scoreDisplayMode, and this should be a group.
but once that's cleaned up it makes sense to do that policy change.
* @param {LH.Result.Category.manualDescription} [manualDescription] | ||
* @return {Element[]} | ||
*/ | ||
_splitAndRenderClumps(auditRefs, groupDefinitions = {}, manualDescription) { |
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.
doesn't the leading underscore still break when rolling to devtools (closure won't like perf-category-rendering trying to access it outside of this file?).
It's also pretty much what render()
was before, so having it as a public method feels as ok as renderAuditGroup
, renderClump
, etc, so I say just go for
_splitAndRenderClumps(auditRefs, groupDefinitions = {}, manualDescription) { | |
renderClumps(auditRefs, groupDefinitions, manualDescription) { |
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.
also should move the really good ascii diagram + description to this method as this is the one actually doing it now
Co-authored-by: Brendan Kenny <bckenny@gmail.com>
dd19244
to
c934c4b
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
const renderedAudits = [...metricAudits, thumbnailAudit, budgetAudit, ...opportunityAudits, | ||
...diagnosticAudits]; | ||
const unrenderedAudits = category.auditRefs.filter(ref => !renderedAudits.includes(ref)); | ||
const remainingAudits = unrenderedAudits.filter(ref => !!ref.group); |
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 sounds good.
it means every auditRef needs a group. but that works for me.
the tricky thing is manual
audits are currently defined by their scoreDisplayMode, and this should be a group.
but once that's cleaned up it makes sense to do that policy change.
* @param {Object<string, LH.Result.ReportGroup>} [groupDefinitions] | ||
* @return {Element} | ||
*/ | ||
render(category, groupDefinitions = {}) { |
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.
const filmstripEl = this.detailsRenderer.render(thumbnailResult.details); | ||
filmstripEl && timelineEl.appendChild(filmstripEl); | ||
// We only expect one of these, but the renderer will support multiple | ||
const thumbnailAudits = category.auditRefs.filter(audit => audit.group === 'filmstrip'); |
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.
Is this breaking? v7? or: support as fallback the old way.
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.
yeah this would break formatting the v6 reports in a new renderer. good call. i'll add a compat bit to also the screenshot-thumbnails
audit
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.
unsure if breaking change
I noticed that perf audits with warnings don't use the
Passed audits but with warnings
clump that @connorjclark added in #6989. Turns out most of the audits that can emit warnings are in perf and pwa, neither of which used the generalized clumping stuff incategory-renderer
.This PR lets the perf cat use the clumping stuff. And makes sure we don't accidentally not render audits (which has been happening to User Timing for a while).
The major fix: any passed audits in perf category with warnings will be rendered in the pre-expanded clump for extra visibility.