Skip to content

Commit

Permalink
tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 6, 2018
1 parent c270219 commit 59de2ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions lighthouse-core/report/html/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CategoryRenderer {
const tmpl = providedTmpl || this.dom.cloneTemplate('#tmpl-lh-audit', this.templateContext);
const auditEl = this.dom.find('.lh-audit', tmpl);
auditEl.id = audit.result.name;
const displayTextEl = this.dom.find('.lh-audit__display-text, .lh-audit__display-text', auditEl);
const displayTextEl = this.dom.find('.lh-audit__display-text', auditEl);
const scoreDisplayMode = audit.result.scoreDisplayMode;

if (audit.result.displayValue) {
Expand All @@ -43,8 +43,10 @@ class CategoryRenderer {

const titleEl = this.dom.find('.lh-audit__title', auditEl);
titleEl.appendChild(this.dom.convertMarkdownCodeSnippets(audit.result.description));
this.dom.find('.lh-audit__description', auditEl)
.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.helpText));
if (audit.result.helpText) {
this.dom.find('.lh-audit__description', auditEl)
.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.helpText));
}

const header = /** @type {!HTMLDetailsElement} */ (this.dom.find('details', auditEl));
if (audit.result.details && audit.result.details.type) {
Expand All @@ -61,7 +63,7 @@ class CategoryRenderer {
auditEl.classList.add(`lh-audit--error`);
displayTextEl.textContent = 'Error!';
displayTextEl.classList.add('tooltip-boundary');
const tooltip = this.dom.createChildOf(displayTextEl, 'div', 'tooltip');
const tooltip = this.dom.createChildOf(displayTextEl, 'div', 'tooltip lh-debug');
tooltip.textContent = audit.result.debugString || 'Report error: no audit information';
} else if (audit.result.debugString) {
const debugStrEl = this.dom.createChildOf(titleEl, 'div', 'lh-debug');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ describe('PerfCategoryRenderer', () => {

const oppAudits = category.audits.filter(audit => audit.group === 'load-opportunities' &&
audit.result.score !== 1);
const oppElements = categoryDOM.querySelectorAll('.lh-load-opportunity');
const oppElements = categoryDOM.querySelectorAll('.lh-audit--load-opportunity');
assert.equal(oppElements.length, oppAudits.length);

const oppElement = oppElements[0];
const oppSparklineBarElement = oppElement.querySelector('.lh-sparkline__bar');
const oppSparklineElement = oppElement.querySelector('.lh-load-opportunity__sparkline');
const oppTitleElement = oppElement.querySelector('.lh-load-opportunity__title');
const oppTitleElement = oppElement.querySelector('.lh-audit__title');
const oppWastedElement = oppElement.querySelector('.lh-audit__display-text');
assert.ok(oppTitleElement.textContent, 'did not render title');
assert.ok(oppSparklineBarElement.style.width, 'did not set sparkline width');
Expand All @@ -113,7 +113,7 @@ describe('PerfCategoryRenderer', () => {
const fakeCategory = Object.assign({}, category, {audits: [auditWithDebug]});
const categoryDOM = renderer.render(fakeCategory, sampleResults.reportGroups);

const debugEl = categoryDOM.querySelector('.lh-load-opportunity .lh-debug');
const debugEl = categoryDOM.querySelector('.lh-audit--load-opportunity .lh-debug');
assert.ok(debugEl, 'did not render debug');
});

Expand All @@ -131,7 +131,7 @@ describe('PerfCategoryRenderer', () => {
const fakeCategory = Object.assign({}, category, {audits: [auditWithDebug]});
const categoryDOM = renderer.render(fakeCategory, sampleResults.reportGroups);

const debugEl = categoryDOM.querySelector('.lh-load-opportunity .lh-debug');
const debugEl = categoryDOM.querySelector('.lh-audit--load-opportunity .lh-debug');
assert.ok(debugEl, 'did not render debug');
});

Expand Down
4 changes: 2 additions & 2 deletions lighthouse-extension/test/extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ describe('Lighthouse chrome extension', function() {


const selectors = {
audits: '.lh-audit,.lh-metric,.lh-load-opportunity',
titles: '.lh-audit__title, .lh-load-opportunity__title, .lh-metric__title',
audits: '.lh-audit, .lh-metric',
titles: '.lh-audit__title, .lh-metric__title',
};

it('should contain all categories', async () => {
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-viewer/test/viewer-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ describe('Lighthouse Viewer', function() {


const selectors = {
audits: '.lh-audit, .lh-metric, .lh-load-opportunity',
titles: '.lh-audit__title, .lh-load-opportunity__title, .lh-metric__title',
audits: '.lh-audit, .lh-metric',
titles: '.lh-audit__title, .lh-metric__title',
};

it('should load with no errors', async () => {
Expand Down

0 comments on commit 59de2ab

Please sign in to comment.