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

fix: dark mode in useCDN case #383

Merged
merged 1 commit into from
Oct 1, 2024
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
3 changes: 3 additions & 0 deletions lib/generate-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions templates/feature-overview.index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<![endif]-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

<!-- Darkmode -->
<script>
<%= darkmodeScript %>
</script>
<% } else { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="../assets/css/bootstrap.min.css" >
Expand Down
6 changes: 5 additions & 1 deletion templates/features-overview.index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/css/dataTables.bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.min.css">

<!-- Darkmode -->
<script>
<%= darkmodeScript %>
</script>
<% } else { %>
<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css" >
Expand Down Expand Up @@ -138,7 +142,7 @@
legend: false,
responsive: false
};

var getColor = function(selector, defaultColor) {
if (document.querySelector(selector)) {
return getComputedStyle(document.querySelector(selector)).color
Expand Down
24 changes: 24 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down