Skip to content

Conversation

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark requested a review from paulirish as a code owner May 24, 2019 23:25
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 👍

}

// 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

}

// 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