-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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: audit warnings are not top-level #5270
Changes from 3 commits
5f6f86d
aa249d4
05f3922
078c2b0
949b591
836d9ef
f484b62
0f0165a
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 |
---|---|---|
|
@@ -85,8 +85,23 @@ class CategoryRenderer { | |
const tooltip = this.dom.createChildOf(textEl, 'div', 'tooltip lh-debug'); | ||
tooltip.textContent = audit.result.errorMessage || 'Report error: no audit information'; | ||
} else if (audit.result.explanation) { | ||
const explanationEl = this.dom.createChildOf(titleEl, 'div', 'lh-debug'); | ||
explanationEl.textContent = audit.result.explanation; | ||
const explEl = this.dom.createChildOf(titleEl, 'div', 'lh-debug lh-debug--explanation'); | ||
explEl.textContent = audit.result.explanation; | ||
} | ||
const warnings = audit.result.warnings; | ||
if (!warnings || warnings.length === 0) return auditEl; | ||
|
||
// Add list of warnings or singular warning | ||
const warningsEl = this.dom.createChildOf(titleEl, 'div', 'lh-debug lh-debug--warnings'); | ||
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. do we have any cases of warning + explanation? if so, does it still look okish :) 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 (warnings.length === 1) { | ||
warningsEl.textContent = `Warning: ${warnings.join('')}`; | ||
} else { | ||
warningsEl.textContent = 'Warnings: '; | ||
const warningsUl = this.dom.createChildOf(warningsEl, 'ul'); | ||
for (const warning of warnings) { | ||
const item = this.dom.createChildOf(warningsUl, 'li'); | ||
item.textContent = warning; | ||
} | ||
} | ||
return auditEl; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,9 @@ class PerformanceCategoryRenderer extends CategoryRenderer { | |
valueEl.textContent = Util.formatDisplayValue(audit.result.displayValue); | ||
|
||
const descriptionEl = this.dom.find('.lh-metric__description', tmpl); | ||
descriptionEl.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description)); | ||
if (audit.result.description) { | ||
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. a little confused by removing the 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. good catch. it's assumed to be there now. |
||
descriptionEl.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description)); | ||
} | ||
|
||
if (audit.result.scoreDisplayMode === 'error') { | ||
descriptionEl.textContent = ''; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ class ReportRenderer { | |
|
||
/** | ||
* Place the AuditResult into the auditDfn (which has just weight & group) | ||
* @param {Object<string, AuditResultJSON>} audits | ||
* @param {Object<string, LH.Audit.Result>} audits | ||
* @param {Array<CategoryJSON>} reportCategories | ||
*/ | ||
static smooshAuditResultsIntoCategories(audits, reportCategories) { | ||
|
@@ -194,29 +194,13 @@ if (typeof module !== 'undefined' && module.exports) { | |
self.ReportRenderer = ReportRenderer; | ||
} | ||
|
||
/** | ||
* @typedef {{ | ||
rawValue: (number|boolean|undefined), | ||
id: string, | ||
title: string, | ||
description: string, | ||
explanation?: string, | ||
errorMessage?: string, | ||
displayValue?: string|Array<string|number>, | ||
scoreDisplayMode: string, | ||
error: boolean, | ||
score: (number|null), | ||
details?: DetailsJSON, | ||
}} AuditResultJSON | ||
*/ | ||
|
||
/** | ||
* @typedef {{ | ||
id: string, | ||
score: (number|null), | ||
weight: number, | ||
group?: string, | ||
result: AuditResultJSON | ||
result: LH.Audit.Result | ||
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. 👍 |
||
}} AuditJSON | ||
*/ | ||
|
||
|
@@ -248,7 +232,7 @@ if (typeof module !== 'undefined' && module.exports) { | |
finalUrl: string, | ||
runWarnings?: Array<string>, | ||
artifacts: {traces: {defaultPass: {traceEvents: Array}}}, | ||
audits: Object<string, AuditResultJSON>, | ||
audits: Object<string, LH.Audit.Result>, | ||
categories: Object<string, CategoryJSON>, | ||
reportCategories: Array<CategoryJSON>, | ||
categoryGroups: Object<string, GroupJSON>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,17 @@ describe('CategoryRenderer', () => { | |
assert.ok(auditDOM.matches('.lh-audit--informative')); | ||
}); | ||
|
||
it('renders audits with warnings', () => { | ||
const auditResult = { | ||
title: 'Audit', | ||
description: 'Learn more', | ||
warnings: ['It may not have worked!'], | ||
score: 1, | ||
}; | ||
const auditDOM = renderer.renderAudit({id: 'foo', score: 1, result: auditResult}); | ||
assert.ok(auditDOM.querySelector('.lh-debug--warnings'), 'did not render debug message'); | ||
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. want to test at least that the warning text is in there as well? And probably want a plural/bulleted test in addition |
||
}); | ||
|
||
it('renders a category', () => { | ||
const category = sampleResults.reportCategories.find(c => c.id === 'pwa'); | ||
const categoryDOM = renderer.render(category, sampleResults.categoryGroups); | ||
|
@@ -114,23 +125,6 @@ describe('CategoryRenderer', () => { | |
category.description = prevDesc; | ||
}); | ||
|
||
// TODO(phulce): revisit if top-level warnings approach is too noisy | ||
it.skip('renders audits with warnings as failed', () => { | ||
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. do we want to render an audit with warnings as failed? or keep it in passed? 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. good policy question! Let's see. here's the possible warnings we have right now (that are placed into Passed) I see the argument for these being visible by default, however in the case of timing/decode, there's not much a user can do about them. Either way, to be visible by default, they'd have to be placed in "Failed" and either we keep the green checkmark or fail them. Both are pretty weird. So I'm comfy with saying that warnings are orthogonal to passing/failing and default report visibility. wdyt? 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. Yeah I don't think there's much anyone can do about them either, I'm fine to hide especially now that we've got Sentry tracking 'em for Httparchive runs 👍 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. oh right, I was good with warnings and failures being independent of each other, but I forgot that means that passing audits with warnings would then be collapsed by default. That definitely takes away from the usefulness of warnings since that means they'll essentially never be seen if the audit is marked as passing. I can kind of see an argument for hiding some warnings normally, not much the user can do about them, but things like "your manifest technically works but you have weird stuff in there that's getting fallbacks" seems worth bringing up even though the audit passed (and even the warnings about lighthouse's shortcomings might be relevant, which is why we made them warnings in the first place e.g. we can't actually verify all your external links or your images are encoded well except for this list of 20 images, which, while you can't make lighthouse fix, you can verify them yourself). So while I would say that the existence of 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. My suggestion in #5273 (comment) was to use warnings as a way to get attention to an issue without penalizing the score. So I would definitely prefer for the warning to be visible by default (not collapsed). I understand that warnings may also be used for things outside of the developer's control so collapsing may make more sense. Is this something that can be configured by the audit at runtime, rather than forcing all warnings to behave the same? I'd also love to see different UI treatment for warnings; not a green check and not a red exclamation. Could it be a yellow/orange exclamation to distinguish it that something's amiss? 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. 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. Sg. broke this into it's own issue: #5327 ("make sure warnings within Passed Audits are visible") |
||
const auditResult = { | ||
title: 'Audit', | ||
description: 'Learn more', | ||
warnings: ['It may not have worked!'], | ||
score: 1, | ||
}; | ||
const audit = {result: auditResult, score: 1}; | ||
const category = {name: 'Fake', description: '', score: 1, audits: [audit]}; | ||
const categoryDOM = renderer.render(category, sampleResults.reportGroups); | ||
assert.ok(categoryDOM.querySelector( | ||
'.lh-category > .lh-audit-group:not(.lh-passed-audits) > .lh-audit'), | ||
'did not render as failed'); | ||
assert.ok(categoryDOM.querySelector('.lh-debug'), 'did not render debug message'); | ||
}); | ||
|
||
it('renders manual audits if the category contains them', () => { | ||
const pwaCategory = sampleResults.reportCategories.find(cat => cat.id === 'pwa'); | ||
const categoryDOM = renderer.render(pwaCategory, sampleResults.categoryGroups); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,8 +135,10 @@ describe('ReportRenderer', () => { | |
const output = renderer.renderReport(sampleResults, container); | ||
|
||
const warningEls = output.querySelectorAll('.lh-run-warnings > ul > li'); | ||
assert.strictEqual(warningEls.length, 1); | ||
assert.ok(/Links.*unsafe/.test(warningEls[0].textContent), 'did not add warning text'); | ||
assert.strictEqual(warningEls.length, sampleResults.runWarnings.length); | ||
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's already a "no |
||
for (const warningEl of warningEls) { | ||
assert.ok(/Links.*unsafe/.test(warningEl.textContent), 'did not add warning text'); | ||
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. shouldn't this just be deleted now that warningEls should be length 0? 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. good call. |
||
} | ||
}); | ||
|
||
it('renders a footer', () => { | ||
|
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.
tests for these will need to be updated (they assert a
.
in there :)