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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lighthouse-core/report/html/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 :)

.some(audit => Boolean(audit.group === 'metrics' && report.audits[audit.id].errorMessage));
if (hasMetricError) {
const toggleInputEl = /** @type {HTMLInputElement} */ (
this._dom.find('.lh-metrics-toggle__input', this._document));
toggleInputEl.checked = true;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,19 @@ describe('ReportUIFeatures', () => {
assert.ok(container.querySelector('.score100'), 'has fireworks treatment');
});
});

describe('metric descriptions', () => {
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

});

it('with error, show by default', () => {
const lhr = JSON.parse(JSON.stringify(sampleResults));
lhr.audits['first-contentful-paint'].errorMessage = 'Error.';
const container = render(lhr);
assert.ok(container.querySelector('.lh-metrics-toggle__input').checked);
});
});
});