From b763737ed9b65bfe98c90b6b24716cca10216573 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Sat, 5 May 2018 19:02:59 -0700 Subject: [PATCH] tests. --- .../report/html/renderer/category-renderer.js | 10 ++++++---- .../renderer/performance-category-renderer-test.js | 8 ++++---- lighthouse-extension/test/extension-test.js | 4 ++-- lighthouse-viewer/test/viewer-test-pptr.js | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lighthouse-core/report/html/renderer/category-renderer.js b/lighthouse-core/report/html/renderer/category-renderer.js index 2be0321dd24f..7d59fc945816 100644 --- a/lighthouse-core/report/html/renderer/category-renderer.js +++ b/lighthouse-core/report/html/renderer/category-renderer.js @@ -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) { @@ -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) { @@ -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'); diff --git a/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js index aa90ef16a60d..050cf45701d4 100644 --- a/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js @@ -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'); @@ -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'); }); @@ -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'); }); diff --git a/lighthouse-extension/test/extension-test.js b/lighthouse-extension/test/extension-test.js index 5af3b6215645..514120b1d669 100644 --- a/lighthouse-extension/test/extension-test.js +++ b/lighthouse-extension/test/extension-test.js @@ -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 () => { diff --git a/lighthouse-viewer/test/viewer-test-pptr.js b/lighthouse-viewer/test/viewer-test-pptr.js index 97b46a9723c3..0a74e68a0a07 100644 --- a/lighthouse-viewer/test/viewer-test-pptr.js +++ b/lighthouse-viewer/test/viewer-test-pptr.js @@ -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 () => {