Skip to content

Commit 05dd9f1

Browse files
committed
Add theme toggle in the HTML report
1 parent 739dd2b commit 05dd9f1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ 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.write('<div id=\"theme-selector\"onClick=$(\"body\").toggleClass(\"dark\")><span><i class=\"fa fa-desktop\"></i></span></div>')";
26+
String EXTENT_ADDITIONAL_CSS = "#theme-selector{cursor:pointer;position:fixed;bottom:10px;left:25px;z-index:9999;}";
2427
}

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)