From 05dd9f1ff5746c21438ecd86216130fe18f20427 Mon Sep 17 00:00:00 2001 From: Bardan Putra Prananto Date: Thu, 28 Nov 2024 16:12:30 +0300 Subject: [PATCH 1/3] Add theme toggle in the HTML report --- .../zerocode/core/constants/ZeroCodeReportConstants.java | 3 +++ .../zerocode/core/domain/builders/ExtentReportsFactory.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java index 855e4a22b..6aec92f04 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java +++ b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java @@ -21,4 +21,7 @@ public interface ZeroCodeReportConstants { String ZEROCODE_JUNIT = "zerocode.junit"; String CHARTS_AND_CSV = "gen-smart-charts-csv-reports"; + // Custom js and css for extent report + String EXTENT_ADDITIONAL_JS = "document.write('
')"; + String EXTENT_ADDITIONAL_CSS = "#theme-selector{cursor:pointer;position:fixed;bottom:10px;left:25px;z-index:9999;}"; } diff --git a/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ExtentReportsFactory.java b/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ExtentReportsFactory.java index 434cf5590..cad3a2290 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ExtentReportsFactory.java +++ b/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ExtentReportsFactory.java @@ -8,6 +8,8 @@ import java.util.Properties; import java.util.Set; +import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.EXTENT_ADDITIONAL_CSS; +import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.EXTENT_ADDITIONAL_JS; import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.REPORT_DISPLAY_NAME_DEFAULT; import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.REPORT_TITLE_DEFAULT; import static org.slf4j.LoggerFactory.getLogger; @@ -56,7 +58,8 @@ public static void attachSystemInfo() { public static ExtentSparkReporter createExtentHtmlReporter(String reportFileName) { extentSparkReporter = new ExtentSparkReporter(reportFileName); - + extentSparkReporter.config().setJs(EXTENT_ADDITIONAL_JS); + extentSparkReporter.config().setCss(EXTENT_ADDITIONAL_CSS); extentSparkReporter.config().setDocumentTitle(REPORT_TITLE_DEFAULT); extentSparkReporter.config().setReportName(REPORT_DISPLAY_NAME_DEFAULT); From 6aded3998a73c200b039a3ad88a1f8aa5e18f0cd Mon Sep 17 00:00:00 2001 From: Bardan Putra Prananto Date: Thu, 28 Nov 2024 20:00:02 +0300 Subject: [PATCH 2/3] Move toggle to top right --- .../zerocode/core/constants/ZeroCodeReportConstants.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java index 6aec92f04..2087faad5 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java +++ b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java @@ -22,6 +22,8 @@ public interface ZeroCodeReportConstants { String CHARTS_AND_CSV = "gen-smart-charts-csv-reports"; // Custom js and css for extent report - String EXTENT_ADDITIONAL_JS = "document.write('
')"; - String EXTENT_ADDITIONAL_CSS = "#theme-selector{cursor:pointer;position:fixed;bottom:10px;left:25px;z-index:9999;}"; + String EXTENT_ADDITIONAL_JS = "document.querySelector('.vheader').insertAdjacentHTML('afterbegin'," + + "'
" + + "
')"; + String EXTENT_ADDITIONAL_CSS = "#theme-selector{margin-right:15px}"; } From 2ddaa2d50a0c4411e924948c60af871a5c3a20d3 Mon Sep 17 00:00:00 2001 From: Bardan Putra Prananto Date: Thu, 28 Nov 2024 20:11:05 +0300 Subject: [PATCH 3/3] Adjust margin and padding --- .../jsmart/zerocode/core/constants/ZeroCodeReportConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java index 2087faad5..c296ddc21 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java +++ b/core/src/main/java/org/jsmart/zerocode/core/constants/ZeroCodeReportConstants.java @@ -25,5 +25,5 @@ public interface ZeroCodeReportConstants { String EXTENT_ADDITIONAL_JS = "document.querySelector('.vheader').insertAdjacentHTML('afterbegin'," + "'
" + "
')"; - String EXTENT_ADDITIONAL_CSS = "#theme-selector{margin-right:15px}"; + String EXTENT_ADDITIONAL_CSS = "#theme-selector{padding-right:12px;padding-left:12px;margin-right:10px}"; }