|
49 | 49 | import org.labkey.test.components.core.ProjectMenu; |
50 | 50 | import org.labkey.test.components.core.login.SetPasswordForm; |
51 | 51 | import org.labkey.test.components.dumbster.EmailRecordTable; |
| 52 | +import org.labkey.test.components.html.RadioButton; |
52 | 53 | import org.labkey.test.components.html.SiteNavBar; |
53 | 54 | import org.labkey.test.components.ui.navigation.UserMenu; |
54 | 55 | import org.labkey.test.pages.core.admin.CustomizeSitePage; |
@@ -112,6 +113,15 @@ public abstract class LabKeySiteWrapper extends WebDriverWrapper |
112 | 113 | private static final String CLIENT_SIDE_ERROR = "Client exception detected"; |
113 | 114 | public final APIUserHelper _userHelper = new APIUserHelper(this); |
114 | 115 |
|
| 116 | + public enum ProductKey |
| 117 | + { |
| 118 | + sampleManagerStarter, |
| 119 | + sampleManagerProfessional, |
| 120 | + labkeyLims, |
| 121 | + limsStarter, |
| 122 | + limsEnterprise, |
| 123 | + } |
| 124 | + |
115 | 125 | public boolean isGuestModeTest() |
116 | 126 | { |
117 | 127 | return false; |
@@ -1693,4 +1703,51 @@ public String getConversionErrorMessage(Object value, String fieldName, Class<?> |
1693 | 1703 |
|
1694 | 1704 | return "Could not convert value '" + value + "' (" + value.getClass().getSimpleName() + ") for " + fieldType + " field '" + fieldName + "'" ; |
1695 | 1705 | } |
| 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 | + } |
1696 | 1753 | } |
0 commit comments