Skip to content

Commit 189df83

Browse files
committed
Merge branch 'develop' into fb_filewatcher_select
2 parents 1e109d7 + 9a4e409 commit 189df83

File tree

6 files changed

+150
-13
lines changed

6 files changed

+150
-13
lines changed

src/org/labkey/test/TestProperties.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.labkey.serverapi.reader.Readers;
2121
import org.labkey.test.util.CspLogUtil;
2222
import org.labkey.test.util.TestLogger;
23+
import org.labkey.test.util.Version;
2324
import org.openqa.selenium.Dimension;
2425

2526
import java.io.File;
@@ -73,6 +74,31 @@ public abstract class TestProperties
7374
TestLogger.error("Failed to load " + propFile.getName() + " file. Running with hard-coded defaults");
7475
ioe.printStackTrace(System.err);
7576
}
77+
78+
final List<String> gradleProperties = List.of("labkeyVersion");
79+
final File serverPropFile = new File(TestFileUtils.getLabKeyRoot(), "gradle.properties");
80+
if (serverPropFile.exists())
81+
{
82+
try (Reader propReader = Readers.getReader(serverPropFile))
83+
{
84+
TestLogger.log("Loading properties from " + serverPropFile.getName());
85+
Properties properties = new Properties();
86+
properties.load(propReader);
87+
for (String key : gradleProperties)
88+
{
89+
if (properties.containsKey(key))
90+
{
91+
System.setProperty(key, properties.getProperty(key));
92+
}
93+
}
94+
}
95+
catch (IOException ioe)
96+
{
97+
TestLogger.error("Failed to load " + serverPropFile.getName() + " file.");
98+
ioe.printStackTrace(System.err);
99+
}
100+
}
101+
76102
}
77103

78104
private static ZoneId browserZoneId = null;
@@ -83,6 +109,19 @@ public static void load()
83109
CspLogUtil.init();
84110
}
85111

112+
/// Get the local enlistment version, stripping everything past the minor version.
113+
/// - `"25.11.0"` -> `"25.11"`
114+
/// - `"25.11-SNAPSHOT"` -> `"25.11"`
115+
/// @return Enlistment Version or `null` if unable to determine
116+
public static Version getProductVersion()
117+
{
118+
Version version = new Version(System.getProperty("labkeyVersion", "1"));
119+
if (version.size() >= 2)
120+
return version.trim(2);
121+
else
122+
return null;
123+
}
124+
86125
public static boolean isTestCleanupSkipped()
87126
{
88127
return !getBooleanProperty("clean", false);

src/org/labkey/test/components/react/QueryChartDialog.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.labkey.test.Locator;
44
import org.labkey.test.WebDriverWrapper;
5+
import org.labkey.test.components.ColorPickerInput;
56
import org.labkey.test.components.bootstrap.ModalDialog;
67
import org.labkey.test.components.html.Checkbox;
78
import org.labkey.test.components.html.Input;
@@ -577,6 +578,72 @@ public void clickDeleteChart(boolean confirmDelete)
577578
}
578579
}
579580

581+
public boolean hasFillColorOption()
582+
{
583+
return elementCache().fillColorPicker.isDisplayed();
584+
}
585+
586+
public QueryChartDialog setFillColor(String hexColor)
587+
{
588+
return setColor(elementCache().fillColorPicker, hexColor);
589+
}
590+
591+
public boolean hasLineColorOption()
592+
{
593+
return elementCache().lineColorPicker.isDisplayed();
594+
}
595+
596+
public QueryChartDialog setLineColor(String hexColor)
597+
{
598+
return setColor(elementCache().lineColorPicker, hexColor);
599+
}
600+
601+
public boolean hasPointColorOption()
602+
{
603+
return elementCache().pointColorPicker.isDisplayed();
604+
}
605+
606+
public QueryChartDialog setPointColor(String hexColor)
607+
{
608+
return setColor(elementCache().pointColorPicker, hexColor);
609+
}
610+
611+
private QueryChartDialog setColor(WebElement colorPickerContainer, String hexColor)
612+
{
613+
Locator.tagWithClassContaining("button", "color-picker__button").findElement(colorPickerContainer).click();
614+
ColorPickerInput colorInput = new ColorPickerInput.ColorPickerInputFinder(getDriver()).findWhenNeeded();
615+
colorInput.setHexValue(hexColor);
616+
colorPickerContainer.click(); // need to click outside the color picker to close it
617+
return this;
618+
}
619+
620+
public boolean hasColorPaletteOption()
621+
{
622+
return elementCache().reactSelectByLabel("Color Palette", true) != null;
623+
}
624+
625+
public QueryChartDialog selectColorPalette(String option)
626+
{
627+
elementCache().reactSelectByLabel("Color Palette").select(option);
628+
return this;
629+
}
630+
631+
public boolean hasLineColorAndStyleSelectOption()
632+
{
633+
return elementCache().reactSelectByLabel("Line Color and Style", true) != null;
634+
}
635+
636+
public QueryChartDialog selectLineColorAndStyleOption(String option, String hexColor)
637+
{
638+
var seriesDropdown = elementCache().reactSelectByLabel("Line Color and Style");
639+
// series select component uses a custom option renderer
640+
seriesDropdown.setOptionLocator((String type) -> Locator.byClass("chart-builder-type-option").withAttribute("data-series-shape", type));
641+
seriesDropdown.select(option);
642+
if (hexColor != null)
643+
setColor(elementCache().seriesColorPicker, hexColor);
644+
return this;
645+
}
646+
580647
@Override
581648
protected ElementCache newElementCache()
582649
{
@@ -602,6 +669,11 @@ protected class ElementCache extends ModalDialog.ElementCache
602669
final Checkbox inheritableCheckbox = Checkbox.Checkbox(Locator.input("inheritable")).findWhenNeeded(settingsPanel);
603670
final Checkbox fullWidthCheckbox = Checkbox.Checkbox(Locator.input("use-full-width")).findWhenNeeded(settingsPanel);
604671

672+
final WebElement fillColorPicker = Locator.byClass("color-picker").withAttribute("data-name", "boxFillColor").refindWhenNeeded(settingsPanel);
673+
final WebElement lineColorPicker = Locator.byClass("color-picker").withAttribute("data-name", "lineColor").refindWhenNeeded(settingsPanel);
674+
final WebElement pointColorPicker = Locator.byClass("color-picker").withAttribute("data-name", "pointFillColor").refindWhenNeeded(settingsPanel);
675+
final WebElement seriesColorPicker = Locator.byClass("color-picker").withAttribute("data-name", "seriesColor").refindWhenNeeded(settingsPanel);
676+
605677
public ReactSelect reactSelectByLabel(String label)
606678
{
607679
return reactSelectByLabel(label, false);

src/org/labkey/test/tests/SampleTypeRenameTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.labkey.test.util.TestDataGenerator;
2222
import org.labkey.test.util.exp.SampleTypeAPIHelper;
2323
import org.labkey.test.util.search.SearchAdminAPIHelper;
24+
import org.openqa.selenium.Keys;
2425
import org.openqa.selenium.WebElement;
2526

2627
import java.io.IOException;
@@ -106,6 +107,11 @@ public void testSampleTypeFieldRename() throws IOException, CommandException
106107
SearchAdminAPIHelper.waitForIndexer();
107108

108109
goToProjectHome();
110+
111+
// Sometimes sample types created by the API don't immediately show up in the UI, a refresh helps.
112+
refresh();
113+
waitForElement(Locator.linkContainingText(sampleTypeName));
114+
109115
SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
110116
UpdateSampleTypePage updatePage = sampleHelper.goToEditSampleType(sampleTypeName);
111117
updatePage.getFieldsPanel().getField(FIELD_INT).setName(FIELD_INT + " Updated");
@@ -173,6 +179,9 @@ public void testCustomViewWithSampleTypeRename()
173179
.verifyTrue(String.format("Doesn't look like custom view '%s' was saved. Fatal error.", customViewName),
174180
menuItems.contains(customViewName));
175181

182+
// Dismiss the menu so it doesn't get in the way.
183+
menu.collapse();
184+
176185
log(String.format("Rename the sample type to '%s'.", SAMPLE_TYPE_NAME_UPDATED));
177186

178187
clickAndWait(editButton);

src/org/labkey/test/tests/upgrade/BaseUpgradeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public abstract class BaseUpgradeTest extends BaseWebDriverTest
3636

3737
protected static final boolean isUpgradeSetupPhase = TestProperties.getBooleanProperty("webtest.upgradeSetup", true);
3838
protected static final Version previousVersion = Optional.ofNullable(trimToNull(System.getProperty("webtest.upgradePreviousVersion")))
39-
.map(Version::new).orElse(null);
39+
.map(Version::new).orElse(TestProperties.getProductVersion());
4040

4141
@Override
4242
protected boolean skipCleanup(boolean afterTest)
@@ -114,7 +114,7 @@ private static class UpgradeVersionCheck implements TestRule
114114
@Override
115115
public void evaluate() throws Throwable
116116
{
117-
Assume.assumeTrue("Test doesn't support upgrading from version: " + previousVersion,
117+
Assume.assumeTrue("Test not valid when upgrading from version: " + previousVersion,
118118
VersionRange.versionRange(earliestVersion, latestVersion).contains(previousVersion)
119119
);
120120
base.evaluate();

src/org/labkey/test/util/ArtifactCollector.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,18 @@
4949
import java.nio.charset.StandardCharsets;
5050
import java.util.ArrayList;
5151
import java.util.Base64;
52-
import java.util.HashMap;
5352
import java.util.List;
5453
import java.util.Map;
54+
import java.util.concurrent.ConcurrentHashMap;
5555
import java.util.concurrent.CopyOnWriteArrayList;
5656
import java.util.concurrent.atomic.AtomicInteger;
57-
import java.util.regex.Pattern;
5857

5958
import static org.labkey.test.TestProperties.isTestRunningOnTeamCity;
6059
import static org.labkey.test.WebTestHelper.isLocalServer;
6160

6261
public class ArtifactCollector
6362
{
64-
private static final Map<String, AtomicInteger> _shotCounters = new HashMap<>();
65-
private static final Pattern _illegalFileCharactersPattern = SystemUtils.IS_OS_WINDOWS
66-
? Pattern.compile("[\\\\/:*?|\"<>]")
67-
: Pattern.compile("/");
63+
private static final Map<String, AtomicInteger> _shotCounters = new ConcurrentHashMap<>();
6864

6965
private final WebDriverWrapper _driver;
7066
private final String _dumpDirName;
@@ -172,7 +168,7 @@ public static void dumpThreads()
172168

173169
private String buildBaseName(@NotNull String suffix)
174170
{
175-
return getAndIncrementShotCounter() + "_" + _illegalFileCharactersPattern.matcher(suffix).replaceAll("_");
171+
return TestFileUtils.makeLegalFileName(getAndIncrementShotCounter() + "_" + suffix);
176172
}
177173

178174
private int getAndIncrementShotCounter()

src/org/labkey/test/util/Version.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,32 @@ public class Version implements Comparable<Version>
1515
{
1616
private final List<Integer> _version;
1717

18-
public Version(Integer... version)
18+
private Version(List<Integer> version)
1919
{
2020
_version = validate(version);
2121
}
2222

23+
public Version(Integer... version)
24+
{
25+
this(List.of(version));
26+
}
27+
2328
public Version(String version)
2429
{
25-
this(Arrays.stream(version.split("\\.")).map(Integer::parseInt).toArray(Integer[]::new));
30+
this(Arrays.stream(version
31+
.split("-", 2)[0] // Remove snapshot suffix
32+
.split("\\.")) // Split the version into major, minor, patch, etc. parts
33+
.map(Integer::parseInt).toList());
2634
}
2735

2836
public Version(Double version)
2937
{
3038
this(version.toString());
3139
}
3240

33-
private static List<Integer> validate(Integer... versionParts)
41+
private static List<Integer> validate(List<Integer> versionParts)
3442
{
35-
List<Integer> partList = List.of(versionParts);
43+
List<Integer> partList = List.copyOf(versionParts);
3644
if (partList.isEmpty())
3745
{
3846
throw new IllegalArgumentException("Version must have at least one part");
@@ -47,6 +55,19 @@ private static List<Integer> validate(Integer... versionParts)
4755
return partList;
4856
}
4957

58+
public Version trim(int maxParts)
59+
{
60+
if (maxParts == _version.size())
61+
return this;
62+
else
63+
return new Version(_version.subList(0, maxParts));
64+
}
65+
66+
public int size()
67+
{
68+
return _version.size();
69+
}
70+
5071
@Override
5172
public int compareTo(@NotNull Version o)
5273
{

0 commit comments

Comments
 (0)