From 494fae318f001f995137a93504eeb3c9cd33ebaf Mon Sep 17 00:00:00 2001 From: Sven Seyfert Date: Tue, 1 Oct 2024 14:12:02 +0200 Subject: [PATCH] fix: dark mode in useCDN case (#383) --- lib/generate-report.js | 3 +++ templates/feature-overview.index.tmpl | 5 +++++ templates/features-overview.index.tmpl | 6 +++++- test/test.js | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/generate-report.js b/lib/generate-report.js index f05fadfe..20a60fa2 100755 --- a/lib/generate-report.js +++ b/lib/generate-report.js @@ -10,6 +10,7 @@ const { Duration } = require('luxon'); const collectJSONS = require('./collect-jsons'); const REPORT_STYLESHEET = 'style.css'; +const DARK_MODE_JS = './assets/js/darkmode.js'; const GENERIC_JS = 'generic.js'; const INDEX_HTML = 'index.html'; const FEATURE_FOLDER = 'features'; @@ -612,6 +613,7 @@ function generateReport(options) { customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), useCDN: suite.useCDN, + darkmodeScript: _readTemplateFile(DARK_MODE_JS), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, @@ -664,6 +666,7 @@ function generateReport(options) { useCDN: suite.useCDN, customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), + darkmodeScript: _readTemplateFile(DARK_MODE_JS), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, diff --git a/templates/feature-overview.index.tmpl b/templates/feature-overview.index.tmpl index dad9408d..7ae506e8 100644 --- a/templates/feature-overview.index.tmpl +++ b/templates/feature-overview.index.tmpl @@ -23,6 +23,11 @@ + + + <% } else { %> diff --git a/templates/features-overview.index.tmpl b/templates/features-overview.index.tmpl index 6651cfe2..be099702 100644 --- a/templates/features-overview.index.tmpl +++ b/templates/features-overview.index.tmpl @@ -26,6 +26,10 @@ + + <% } else { %> @@ -138,7 +142,7 @@ legend: false, responsive: false }; - + var getColor = function(selector, defaultColor) { if (document.querySelector(selector)) { return getComputedStyle(document.querySelector(selector)).color diff --git a/test/test.js b/test/test.js index 875b6ffb..1b5b9fa7 100644 --- a/test/test.js +++ b/test/test.js @@ -26,6 +26,30 @@ test.generate({ } }); +/** + * Generate a report for browsers wit useCDN true + */ +test.generate({ + saveCollectedJSON: true, + jsonDir: './test/unit/data/json/', + reportPath: './.tmp/browsers-with-cdn-usage/', + reportName: 'Report with CDN usage', + customMetadata: false, + displayDuration: true, + durationInMS: true, + useCDN: true, + customData: { + title: 'Run info', + data: [ + {label: 'Project', value: 'Custom project'}, + {label: 'Release', value: '1.2.3'}, + {label: 'Cycle', value: 'B11221.34321'}, + {label: 'Execution Start Time', value: 'Nov 19th 2017, 02:31 PM EST'}, + {label: 'Execution End Time', value: 'Nov 19th 2017, 02:56 PM EST'} + ] + } +}); + /** * Generate a report with array of embedded data */