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: show metric descriptions by default when errors exist #9054

Merged
merged 3 commits into from
May 30, 2019

Conversation

connorjclark
Copy link
Collaborator

it('with no errors, hide by default', () => {
const lhr = JSON.parse(JSON.stringify(sampleResults));
const container = render(lhr);
assert.ok(!container.querySelector('.lh-metrics-toggle__input').checked);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these assertions seem questionable..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as in, I'm very explicitly testing against the if statement. idk seems odd

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah it feels like we really just want to assert that the errors are visible, do we do any gCS in these UI tests yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gCS?

I first tried to do something like "are the description elements visible", but I don't think we can do that b/c jsdom doesn't try to surface stuff like that. as in, there is no rendering/css engine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought styles directly applied to elements still resolved though? I could be wrong I just thought there was no cascading.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, so I was actually thinking of layout (from reading this). Tried a bit more, but still no dice:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LOL I forgot we shim getComputedStyles in this test. I thought it was provided by jsdom. anyways, idk how to do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so if we don't overwrite their getComputedStyles, this happens:

image

weird

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM assuming metrics failure scenarios are expected 👍

@@ -117,6 +117,13 @@ class ReportUIFeatures {
this._document.addEventListener('scroll', this._updateStickyHeaderOnScroll);
window.addEventListener('resize', this._updateStickyHeaderOnScroll);
}

// Show the metric descriptions by default when there is an error.
if (report.audits.metrics.errorMessage) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

worth noting that TTI, speed index, and FCPUI will just be undefined and not throw an errorMessage onto metrics so this will only handle it for fcp/fmp/eil/traceOfTab errors

but that seems to be the case we want to auto-expand anyhow, when all of them fail basically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My intention was to expand if there are any "Error"s in the metric table. I assumed audits.metrics.errorMessage would be that, but that's probably a bad assumption...

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah you'll probably want to switch to report.audits['first-contentful-paint'].errorMessage || report.audits.interactive.errorMessage || ... then :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

figured it out

@@ -117,6 +117,15 @@ class ReportUIFeatures {
this._document.addEventListener('scroll', this._updateStickyHeaderOnScroll);
window.addEventListener('resize', this._updateStickyHeaderOnScroll);
}

// Show the metric descriptions by default when there is an error.
const hasMetricError = report.categories.performance && report.categories.performance.auditRefs
Copy link
Collaborator

Choose a reason for hiding this comment

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

even better :)

@connorjclark connorjclark merged commit ffaea60 into master May 30, 2019
@brendankenny brendankenny deleted the show-metric-descs-on-error branch May 30, 2019 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants