From 0afb6ad10a4af0ea93557ffe8cd9e4ddbff3447a Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 9 Jul 2025 09:24:10 -0700 Subject: [PATCH] Allow `ScriptReportPage.saveReport` to return `null` --- .../test/pages/reports/ScriptReportPage.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/org/labkey/test/pages/reports/ScriptReportPage.java b/src/org/labkey/test/pages/reports/ScriptReportPage.java index 31b0db491e..a037747028 100644 --- a/src/org/labkey/test/pages/reports/ScriptReportPage.java +++ b/src/org/labkey/test/pages/reports/ScriptReportPage.java @@ -17,8 +17,9 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.Map; -import java.util.Objects; import java.util.Optional; import static org.labkey.test.components.ext4.Checkbox.Ext4Checkbox; @@ -89,12 +90,25 @@ public String saveReport(String name, boolean isSaveAs, int wait) { saveReportWithName(name, isSaveAs); } - return Objects.requireNonNullElse(getReportId(), reportIdBeforeSave); + String reportIdAfterSave = getReportId(); + return reportIdAfterSave == null ? reportIdBeforeSave : reportIdAfterSave; } public String getReportId() { - return getUrlParam("reportId", true); + String paramName = "reportId"; + + Map params = WebTestHelper.parseUrlQuery(getURL()); + String paramValue = params.get(paramName); + + if (paramValue == null) + { + paramValue = params.entrySet().stream() + .filter(entry -> entry.getKey().endsWith("." + paramName)) + .map(Map.Entry::getValue).findFirst().orElse(null); + } + + return paramValue == null ? null : URLDecoder.decode(paramValue, StandardCharsets.UTF_8); } /**