-
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(redesign): order gauges - default, pwa, plugins #8529
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,20 +223,23 @@ class ReportRenderer { | |
// } | ||
|
||
if (scoreHeader) { | ||
const defaultGauges = []; | ||
const customGauges = []; | ||
// Group gauges in this order: mainstream, pwa, plugins. | ||
const mainstreamGauges = []; | ||
const customGauges = []; // PWA. | ||
const pluginGauges = []; | ||
for (const category of report.reportCategories) { | ||
const renderer = specificCategoryRenderers[category.id] || categoryRenderer; | ||
const categoryGauge = renderer.renderScoreGauge(category, report.categoryGroups || {}); | ||
|
||
// Group gauges that aren't default at the end of the header | ||
if (renderer.renderScoreGauge === categoryRenderer.renderScoreGauge) { | ||
defaultGauges.push(categoryGauge); | ||
if (Util.isPluginCategory(category.id)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol great |
||
pluginGauges.push(categoryGauge); | ||
} else if (renderer.renderScoreGauge === categoryRenderer.renderScoreGauge) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems like an interesting way to tell, I guess the point is "do we render this gauge exactly like the others or does the gauge look different"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i 100% don't understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's confusing, should keep the comment :) (or make it more informative!) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
mainstreamGauges.push(categoryGauge); | ||
} else { | ||
customGauges.push(categoryGauge); | ||
} | ||
} | ||
scoreHeader.append(...defaultGauges, ...customGauges); | ||
scoreHeader.append(...mainstreamGauges, ...customGauges, ...pluginGauges); | ||
|
||
const scoreScale = this._dom.cloneTemplate('#tmpl-lh-scorescale', this._templateContext); | ||
const scoresContainer = this._dom.find('.lh-scores-container', headerContainer); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,21 +104,38 @@ describe('ReportRenderer', () => { | |
assert.ok(header.querySelector('.lh-scores-container'), 'contains score container'); | ||
}); | ||
|
||
it('renders special score gauges after the mainstream ones', () => { | ||
it('renders score gauges in this order: mainstream, pwa, plugins', () => { | ||
const sampleResultsCopy = JSON.parse(JSON.stringify(sampleResults)); | ||
sampleResultsCopy.categories['lighthouse-plugin-someplugin'] = { | ||
id: 'lighthouse-plugin-someplugin', | ||
title: 'Some Plugin', | ||
auditRefs: [], | ||
}; | ||
|
||
const container = renderer._dom._document.body; | ||
const output = renderer.renderReport(sampleResults, container); | ||
const output = renderer.renderReport(sampleResultsCopy, container); | ||
|
||
const indexOfFirstIrregularGauge = Array.from(output | ||
const indexOfPwaGauge = Array.from(output | ||
.querySelectorAll('.lh-scores-header > a[class*="lh-gauge"]')).findIndex(el => { | ||
return el.matches('.lh-gauge--pwa__wrapper'); | ||
}); | ||
|
||
const indexOfPluginGauge = Array.from(output | ||
.querySelectorAll('.lh-scores-header > a[class*="lh-gauge"]')).findIndex(el => { | ||
return el.matches('.lh-gauge__wrapper--plugin'); | ||
}); | ||
|
||
assert.notEqual(-1, indexOfPwaGauge); | ||
assert.notEqual(-1, indexOfPluginGauge); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like we also want to assert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
const scoresHeaderElem = output.querySelector('.lh-scores-header'); | ||
for (let i = 0; i < scoresHeaderElem.children.length; i++) { | ||
const gauge = scoresHeaderElem.children[i]; | ||
|
||
assert.ok(gauge.classList.contains('lh-gauge__wrapper')); | ||
if (i >= indexOfFirstIrregularGauge) { | ||
if (i >= indexOfPluginGauge) { | ||
assert.ok(gauge.classList.contains('lh-gauge__wrapper--plugin')); | ||
} else if (i >= indexOfPwaGauge) { | ||
assert.ok(gauge.classList.contains('lh-gauge--pwa__wrapper')); | ||
} | ||
} | ||
|
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.
can we still use "deault" (from
default-config.js
) or "core" for these?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