Skip to content

Commit c86bb83

Browse files
authored
Merge pull request #697 from bppdanto-t/add-theme-toggle
Add theme toggle in HTML report
2 parents 739dd2b + 2ddaa2d commit c86bb83

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ public interface ZeroCodeReportConstants {
2121
String ZEROCODE_JUNIT = "zerocode.junit";
2222
String CHARTS_AND_CSV = "gen-smart-charts-csv-reports";
2323

24+
// Custom js and css for extent report
25+
String EXTENT_ADDITIONAL_JS = "document.querySelector('.vheader').insertAdjacentHTML('afterbegin'," +
26+
"'<div id=\"theme-selector\"class=\"nav-right\"onClick=$(\"body\").toggleClass(\"dark\")>" +
27+
"<span class=\"badge badge-primary\"><i class=\"fa fa-desktop\"></i></span></div>')";
28+
String EXTENT_ADDITIONAL_CSS = "#theme-selector{padding-right:12px;padding-left:12px;margin-right:10px}";
2429
}

core/src/main/java/org/jsmart/zerocode/core/domain/builders/ExtentReportsFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.Properties;
99
import java.util.Set;
1010

11+
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.EXTENT_ADDITIONAL_CSS;
12+
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.EXTENT_ADDITIONAL_JS;
1113
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.REPORT_DISPLAY_NAME_DEFAULT;
1214
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.REPORT_TITLE_DEFAULT;
1315
import static org.slf4j.LoggerFactory.getLogger;
@@ -56,7 +58,8 @@ public static void attachSystemInfo() {
5658
public static ExtentSparkReporter createExtentHtmlReporter(String reportFileName) {
5759
extentSparkReporter = new ExtentSparkReporter(reportFileName);
5860

59-
61+
extentSparkReporter.config().setJs(EXTENT_ADDITIONAL_JS);
62+
extentSparkReporter.config().setCss(EXTENT_ADDITIONAL_CSS);
6063
extentSparkReporter.config().setDocumentTitle(REPORT_TITLE_DEFAULT);
6164
extentSparkReporter.config().setReportName(REPORT_DISPLAY_NAME_DEFAULT);
6265

0 commit comments

Comments
 (0)