Skip to content

Commit 7918427

Browse files
committed
Merge branch 'develop' into fb_issue_51695
2 parents 8414acf + a56522e commit 7918427

22 files changed

Lines changed: 941 additions & 174 deletions

src/org/labkey/test/TestProperties.java

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.apache.commons.lang3.SystemUtils;
2020
import org.labkey.serverapi.reader.Readers;
21+
import org.labkey.test.util.CspLogUtil;
2122
import org.labkey.test.util.TestLogger;
2223
import org.openqa.selenium.Dimension;
2324

@@ -30,6 +31,7 @@
3031
import java.time.LocalDateTime;
3132
import java.time.ZoneId;
3233
import java.util.Arrays;
34+
import java.util.Collections;
3335
import java.util.HashMap;
3436
import java.util.Iterator;
3537
import java.util.List;
@@ -78,6 +80,7 @@ public abstract class TestProperties
7880
public static void load()
7981
{
8082
/* Force static block to run */
83+
CspLogUtil.init();
8184
}
8285

8386
public static boolean isTestCleanupSkipped()
@@ -129,7 +132,7 @@ public static boolean isQueryCheckSkipped()
129132

130133
public static boolean isCspCheckSkipped()
131134
{
132-
return !getBooleanProperty("webtest.cspCheck", false);
135+
return !getBooleanProperty("webtest.cspCheck", true);
133136
}
134137

135138
public static boolean isNewWebDriverForEachTest()
@@ -264,6 +267,10 @@ public static boolean isAssayProductFeatureAvailable()
264267
return isProductFeatureAvailable("assay");
265268
}
266269

270+
/**
271+
* Product features are assumed to be available unless the test environment (usually TeamCity) explicitly specifies
272+
* that it is not.
273+
*/
267274
public static boolean isProductFeatureAvailable(String feature)
268275
{
269276
return "true".equals(System.getProperty("webtest.productFeature." + feature.toLowerCase(), "true"));
@@ -276,7 +283,7 @@ public static boolean ignoreDatabaseNotSupportedException()
276283

277284
/**
278285
* Parses system property 'webtest.server.startup.timeout' to determine maximum allowed server startup time.
279-
* If property is not defined or is not an integer, it defaults to 60 seconds.
286+
* If property is not defined or is not an integer, it defaults to 120 seconds.
280287
* @return Maximum number of seconds to wait for server startup
281288
*/
282289
public static int getServerStartupTimeout()
@@ -289,34 +296,48 @@ public static String getAdditionalPipelineTools()
289296
return System.getProperty("additional.pipeline.tools");
290297
}
291298

299+
private static Map<String, Boolean> _optionalFeatures = null;
292300
public static Map<String, Boolean> getOptionalFeatures()
293301
{
294-
Map<String, Boolean> features = new HashMap<>();
295-
296-
Properties props = System.getProperties();
297-
for (Map.Entry<Object, Object> entry : props.entrySet())
302+
if (_optionalFeatures == null)
298303
{
299-
String key = String.valueOf(entry.getKey());
300-
Boolean value = (entry.getValue() instanceof Boolean)
301-
? (Boolean)entry.getValue()
302-
: Boolean.valueOf(String.valueOf(entry.getValue()));
304+
Map<String, Boolean> features = new HashMap<>();
303305

304-
String prefix = "webtest.experimental."; // Can be used with any optional feature flags; "experimental" is used for backward-compatibility purposes.
305-
if (key.startsWith(prefix))
306+
Properties props = System.getProperties();
307+
for (Map.Entry<Object, Object> entry : props.entrySet())
306308
{
307-
String feature = key.substring(prefix.length());
308-
features.put(feature, value);
309+
String key = String.valueOf(entry.getKey());
310+
311+
String expPrefix = "webtest.experimental."; // "experimental" is accepted for backward-compatibility purposes.
312+
String optPrefix = "webtest.optional."; // Preferred prefix
313+
for (String prefix : List.of(expPrefix, optPrefix))
314+
{
315+
if (key.startsWith(prefix))
316+
{
317+
Boolean value = (entry.getValue() instanceof Boolean)
318+
? (Boolean) entry.getValue()
319+
: Boolean.valueOf(String.valueOf(entry.getValue()));
320+
String feature = key.substring(prefix.length());
321+
features.put(feature, value);
322+
}
323+
}
309324
}
310-
}
311325

312-
return features;
326+
_optionalFeatures = Collections.unmodifiableMap(features);
327+
}
328+
return _optionalFeatures;
313329
}
314330

331+
private static List<String> debugLoggingPackages = null;
315332
public static List<String> getDebugLoggingPackages()
316333
{
317-
String prop = System.getProperty("webtest.debug.server.packages", "");
318-
String[] packages = prop.split("\\s*,\\s*");
319-
return Arrays.stream(packages).map(String::trim).filter(s -> !s.isEmpty()).collect(Collectors.toList());
334+
if (debugLoggingPackages == null)
335+
{
336+
String prop = System.getProperty("webtest.debug.server.packages", "");
337+
String[] packages = prop.split(",");
338+
debugLoggingPackages = Arrays.stream(packages).map(String::trim).filter(s -> !s.isEmpty()).collect(Collectors.toList());
339+
}
340+
return debugLoggingPackages;
320341
}
321342

322343
private static File dumpDir = null;

src/org/labkey/test/WebDriverWrapper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public <T> T executeScript(@Language("JavaScript") String script, Class<T> expec
542542
* Wrapper for synchronous execution of asynchronous JavaScript. This wrapper extracts the 'callback' from the argument list
543543
* See {@link JavascriptExecutor#executeAsyncScript(java.lang.String, java.lang.Object...)} for details
544544
*/
545-
public Object executeAsyncScript(@Language("XPath") String script, Object... arguments)
545+
public Object executeAsyncScript(@Language("JavaScript") String script, Object... arguments)
546546
{
547547
script = "var callback = arguments[arguments.length - 1];\n" + // See WebDriver documentation for details on injected callback
548548
"try {" +
@@ -551,7 +551,7 @@ public Object executeAsyncScript(@Language("XPath") String script, Object... arg
551551
return ((JavascriptExecutor) getDriver()).executeAsyncScript(script, arguments);
552552
}
553553

554-
public <T> T executeAsyncScript(String script, Class<T> expectedResultType, Object... arguments)
554+
public <T> T executeAsyncScript(@Language("JavaScript") String script, Class<T> expectedResultType, Object... arguments)
555555
{
556556
Object o = executeAsyncScript(script, arguments);
557557
if (o != null && !expectedResultType.isAssignableFrom(o.getClass()))
@@ -2738,6 +2738,12 @@ public String getSelectedOptionText(WebElement el)
27382738
return select.getFirstSelectedOption().getText();
27392739
}
27402740

2741+
public List<String> getSelectedOptionTexts(Locator loc)
2742+
{
2743+
Select select = new Select(loc.findElement(getDriver()));
2744+
return select.getAllSelectedOptions().stream().map(WebElement::getText).collect(Collectors.toList());
2745+
}
2746+
27412747
public String getSelectedOptionValue(Locator loc)
27422748
{
27432749
return getSelectedOptionValue(loc.findElement(getDriver()));

src/org/labkey/test/components/domain/DomainFormPanel.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.stream.Collectors;
2828

2929
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
30+
import static org.labkey.test.WebDriverWrapper.waitFor;
3031

3132
/**
3233
* Automates the LabKey ui component defined in: packages/components/src/components/domainproperties/DomainForm.tsx
@@ -43,6 +44,12 @@ private DomainFormPanel(WebElement element, WebDriver driver)
4344
super(element, driver);
4445
}
4546

47+
@Override
48+
protected void waitForReady()
49+
{
50+
waitFor(() -> !BootstrapLocators.loadingSpinner.existsIn(this), "Loading spinner still present", 2_000);
51+
}
52+
4653
public static List<AdvancedFieldSetting> advancedSettingsFromFieldDefinition(FieldDefinition def)
4754
{
4855
List<AdvancedFieldSetting> advancedSettings = new ArrayList<>();
@@ -256,8 +263,8 @@ else if (validator instanceof FieldDefinition.TextChoiceValidator textChoiceVali
256263
*/
257264
public DomainFormPanel clickManuallyDefineFields()
258265
{
259-
getWrapper().scrollIntoView(elementCache().manuallyDefineButton, true);
260266
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(elementCache().manuallyDefineButton)); // give modal dialogs time to disappear
267+
getWrapper().scrollIntoView(elementCache().manuallyDefineButton, true);
261268
elementCache().manuallyDefineButton.click();
262269

263270
return this;

src/org/labkey/test/components/html/Table.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public int getRowCount()
8888
return elementCache().getRows().size();
8989
}
9090

91+
public List<WebElement> getRows()
92+
{
93+
return elementCache().getRows();
94+
}
95+
9196
/**
9297
* For a well formed html table get the text from the th elements in the thead.
9398
*

src/org/labkey/test/components/ui/grids/ResponsiveGrid.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,24 @@ public List<String> getColumnLabels()
642642
return elementCache().getColumnLabels();
643643
}
644644

645+
/**
646+
*
647+
* @return a List&#60;String&#62; containing the names of the fields for each column header
648+
*/
649+
public List<String> getColumnNames()
650+
{
651+
return elementCache().getColumnNames();
652+
}
653+
654+
/**
655+
*
656+
* @return a List&#60;FieldKey&#62; containing the fieldKeys for each column header
657+
*/
658+
public List<FieldKey> getColumnFieldKeys()
659+
{
660+
return elementCache().getColumnFieldKeys();
661+
}
662+
645663
/**
646664
* Get data from a row
647665
* @param rowIndex the index of the desired row
@@ -773,7 +791,7 @@ public Optional<String> getGridEmptyMessage()
773791
return msg;
774792
}
775793

776-
List<FieldReference> getHeaders()
794+
public List<FieldReference> getHeaders()
777795
{
778796
return Collections.unmodifiableList(elementCache().findHeaders());
779797
}
@@ -861,6 +879,16 @@ protected List<String> getColumnLabels()
861879
return findHeaders().stream().map(FieldReferenceManager.FieldReference::getLabel).collect(Collectors.toList());
862880
}
863881

882+
protected List<String> getColumnNames()
883+
{
884+
return findHeaders().stream().map(FieldReferenceManager.FieldReference::getName).collect(Collectors.toList());
885+
}
886+
887+
protected List<FieldKey> getColumnFieldKeys()
888+
{
889+
return findHeaders().stream().map(FieldReferenceManager.FieldReference::getFieldKey).collect(Collectors.toList());
890+
}
891+
864892
protected GridRow getRow(int index)
865893
{
866894
return getRows().get(index);

0 commit comments

Comments
 (0)