Skip to content

Commit 37024cd

Browse files
authored
TargetedMSSampleManagerIntegrationTest update to check for LKSM and LIMS product configuration cases (#2478)
- Move ProductKey and setProductConfiguration helpers to BaseWebDriverTest from SMBaseTest
1 parent ce5e1cd commit 37024cd

File tree

3 files changed

+59
-23
lines changed

3 files changed

+59
-23
lines changed

src/org/labkey/test/LabKeySiteWrapper.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.labkey.test.components.core.ProjectMenu;
5050
import org.labkey.test.components.core.login.SetPasswordForm;
5151
import org.labkey.test.components.dumbster.EmailRecordTable;
52+
import org.labkey.test.components.html.RadioButton;
5253
import org.labkey.test.components.html.SiteNavBar;
5354
import org.labkey.test.components.ui.navigation.UserMenu;
5455
import org.labkey.test.pages.core.admin.CustomizeSitePage;
@@ -112,6 +113,15 @@ public abstract class LabKeySiteWrapper extends WebDriverWrapper
112113
private static final String CLIENT_SIDE_ERROR = "Client exception detected";
113114
public final APIUserHelper _userHelper = new APIUserHelper(this);
114115

116+
public enum ProductKey
117+
{
118+
sampleManagerStarter,
119+
sampleManagerProfessional,
120+
labkeyLims,
121+
limsStarter,
122+
limsEnterprise,
123+
}
124+
115125
public boolean isGuestModeTest()
116126
{
117127
return false;
@@ -1693,4 +1703,51 @@ public String getConversionErrorMessage(Object value, String fieldName, Class<?>
16931703

16941704
return "Could not convert value '" + value + "' (" + value.getClass().getSimpleName() + ") for " + fieldType + " field '" + fieldName + "'" ;
16951705
}
1706+
1707+
private ProductKey getProductConfiguration() throws IOException, CommandException
1708+
{
1709+
SimpleGetCommand command = new SimpleGetCommand("admin", "productFeature");
1710+
var resp = command.execute(createDefaultConnection(), "/");
1711+
String keyString = resp.getProperty("productKey");
1712+
if (keyString == null)
1713+
return null;
1714+
1715+
return ProductKey.valueOf(keyString);
1716+
}
1717+
1718+
protected ProductKey setProductConfigurationViaApi(@Nullable ProductKey productKey) throws IOException, CommandException
1719+
{
1720+
ProductKey existing = getProductConfiguration();
1721+
log("Setting product key to " + (productKey == null ? "null" : productKey));
1722+
Map<String, Object> parameters = new HashMap<>();
1723+
parameters.put("productKey", productKey == null ? null : productKey.toString());
1724+
1725+
SimplePostCommand command = new SimplePostCommand("admin", "productfeature");
1726+
command.setParameters(parameters);
1727+
var resp = command.execute(createDefaultConnection(), "/");
1728+
if (resp.getStatusCode() == 200)
1729+
log("Successfully updated product key.");
1730+
else
1731+
throw new CommandException("Failed to set product key.");
1732+
return existing;
1733+
}
1734+
1735+
/**
1736+
* Goes to the Admin / Product Configuration page and selects the designated product. Will navigate back to current URL.
1737+
*
1738+
*/
1739+
protected void setProductConfiguration(ProductKey productKey)
1740+
{
1741+
if (productKey == null)
1742+
return;
1743+
1744+
String currentUrl = getCurrentRelativeURL();
1745+
1746+
goToAdminConsole();
1747+
clickAndWait(Locator.linkWithText("product configuration"));
1748+
RadioButton radioButton = new RadioButton.RadioButtonFinder().withValue(productKey.name()).find(getDriver());
1749+
radioButton.check();
1750+
1751+
beginAt(currentUrl);
1752+
}
16961753
}

src/org/labkey/test/WebDriverWrapper.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -769,20 +769,11 @@ public List<String> getFormAddresses()
769769
return (List<String>) executeScript(js);
770770
}
771771

772-
public String getCurrentRelativeURL()
773-
{
774-
return getCurrentRelativeURL(true);
775-
}
776-
777772
/**
778773
* Get the relative URL for the current page. The host, port, and context path are removed.
779-
* Trailing '?' will be removed (optionally) to make comparisons more consistent when enabling the 'noQuestionMarkUrl' experimental feature.
780-
* Leaving the trailing question mark can be useful when comparing to a URL generated by 'URLBuilder' because it
781-
* knows about the experimental feature.
782-
* @param stripTrailingQuestionMark false to leave it if it exists.
783774
* @return The relative URL or 'null' if the browser is not currently showing the server under test.
784775
*/
785-
public String getCurrentRelativeURL(boolean stripTrailingQuestionMark)
776+
public String getCurrentRelativeURL()
786777
{
787778
URL url = getURL();
788779
String urlString = getDriver().getCurrentUrl();
@@ -798,18 +789,6 @@ public String getCurrentRelativeURL(boolean stripTrailingQuestionMark)
798789
TestLogger.warn("Expected URL to begin with " + baseURL + ", but found " + urlString);
799790
return null;
800791
}
801-
if (stripTrailingQuestionMark)
802-
{
803-
// Strip '?' if no query
804-
if (urlString.contains("#"))
805-
{
806-
urlString = urlString.replace("?#", "#");
807-
}
808-
else
809-
{
810-
urlString = StringUtils.stripEnd(urlString, "?");
811-
}
812-
}
813792
return urlString.substring(baseURL.length());
814793
}
815794

src/org/labkey/test/tests/list/ListTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ public void customizeURLTest()
20692069
assertElementPresent(inputWithValue("key","1"));
20702070
assertElementPresent(inputWithValue("table","C"));
20712071
assertElementPresent(inputWithValue("title","one C"));
2072-
assertTrue(getCurrentRelativeURL(false).contains(WebTestHelper.buildRelativeUrl("junit", PROJECT_VERIFY, "echoForm")));
2072+
assertTrue(getCurrentRelativeURL().contains(WebTestHelper.buildRelativeUrl("junit", PROJECT_VERIFY, "echoForm")));
20732073
}
20742074
popLocation();
20752075
}

0 commit comments

Comments
 (0)