Skip to content

Commit 532e0b2

Browse files
committed
Merge branch 'develop' into fb_amountsAndUnits
2 parents a03d796 + 10fd8eb commit 532e0b2

17 files changed

Lines changed: 305 additions & 122 deletions

src/org/labkey/test/AssayAPITest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ public void testImportRun_dataRows() throws Exception
311311
assayHelper.importAssay(assayId, runName, dataRowsInvalidResultFileDirectory, getProjectName(), Collections.singletonMap("RunFileField", CREST_FILE.getName()), Collections.emptyMap(), "DataFileField: Invalid file path: ../");
312312

313313
// valid run file and valid result file
314-
FileBrowserHelper.FileDetailInfo runFileInfo = _fileBrowserHelper.getFileDetailInfo(getProjectName(), CREST_FILE.getName());
315-
FileBrowserHelper.FileDetailInfo resultFileInfo = _fileBrowserHelper.getFileDetailInfo(getProjectName(), SCREENSHOT_FILE.getName());
314+
FileBrowserHelper.FileDetailInfo runFileInfo = FileBrowserHelper.getFileDetailInfo(getProjectName(), CREST_FILE.getName());
315+
FileBrowserHelper.FileDetailInfo resultFileInfo = FileBrowserHelper.getFileDetailInfo(getProjectName(), SCREENSHOT_FILE.getName());
316316
List<Pair<String, String>> scenarios = List.of(new Pair<>(CREST_FILE.getName(), SCREENSHOT_FILE.getName()),
317317
new Pair<>(runFileInfo.absoluteFilePath(), resultFileInfo.absoluteFilePath()),
318318
new Pair<>(runFileInfo.webDavUrl(), resultFileInfo.webDavUrl()),
@@ -388,7 +388,7 @@ public void testGpatSaveBatch() throws Exception
388388
goToModule("FileContent");
389389
_fileBrowserHelper.uploadFile(HELP_ICON_FILE);
390390
goToManageAssays();
391-
FileBrowserHelper.FileDetailInfo runFileInfo = _fileBrowserHelper.getFileDetailInfo(getProjectName(), "help.jpg");
391+
FileBrowserHelper.FileDetailInfo runFileInfo = FileBrowserHelper.getFileDetailInfo(getProjectName(), "help.jpg");
392392
((APIAssayHelper) _assayHelper).saveBatch(assayName, "Valid absolute path", Collections.singletonMap("RunFileField", runFileInfo.absoluteFilePath()), resultRows, getProjectName(), null);
393393
((APIAssayHelper) _assayHelper).saveBatch(assayName, "Valid webdav full path", Collections.singletonMap("RunFileField", runFileInfo.webDavUrl()), resultRows, getProjectName(), null);
394394
((APIAssayHelper) _assayHelper).saveBatch(assayName, "Valid webdav relative path", Collections.singletonMap("RunFileField", runFileInfo.webDavUrlRelative()), resultRows, getProjectName(), null);

src/org/labkey/test/BaseWebDriverTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,8 +2307,12 @@ public NewQueryPage createNewQuery(@NotNull String schemaName, @Nullable String
23072307
return new NewQueryPage(getDriver());
23082308
}
23092309

2310-
23112310
protected void createQuery(String container, String name, String schemaName, String sql, String xml, boolean inheritable)
2311+
{
2312+
createQuery(container, name, schemaName, sql, xml, inheritable, null);
2313+
}
2314+
2315+
protected void createQuery(String container, String name, String schemaName, String sql, String xml, boolean inheritable, @Nullable String description)
23122316
{
23132317
SourceQueryPage sourcePage = createQuery(container, name, schemaName);
23142318
sourcePage.setSource(sql);
@@ -2318,10 +2322,15 @@ protected void createQuery(String container, String name, String schemaName, Str
23182322
sourcePage.setMetadataXml(xml);
23192323
}
23202324
sourcePage.clickSave(); // This seems very slow... maybe clickSaveAndFinish() instead?
2321-
if (inheritable)
2325+
if (inheritable || !StringUtils.isEmpty(description))
23222326
{
2327+
String queryURL = buildURL("query", getProjectName(), "begin", Map.of("schemaName", schemaName));
2328+
beginAt(queryURL);
23232329
editQueryProperties(schemaName, name);
2324-
selectOptionByValue(Locator.name("inheritable"), "true");
2330+
if (inheritable)
2331+
selectOptionByValue(Locator.name("inheritable"), "true");
2332+
if (description != null)
2333+
setFormElement(Locator.tagWithName("textarea", "description"), description);
23252334
clickButton("Save");
23262335
}
23272336
}

src/org/labkey/test/Locator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.commons.lang3.StringUtils;
2020
import org.apache.commons.lang3.mutable.MutableObject;
2121
import org.intellij.lang.annotations.Language;
22+
import org.jetbrains.annotations.Contract;
2223
import org.jetbrains.annotations.NotNull;
2324
import org.jetbrains.annotations.Nullable;
2425
import org.labkey.test.selenium.LazyWebElement;
@@ -373,11 +374,13 @@ protected static <T> T extractInputFromFluentWait(FluentWait<T> wait)
373374
return wrappedContext.getValue();
374375
}
375376

377+
@Contract(pure = true)
376378
public LazyWebElement<?> findWhenNeeded(SearchContext context)
377379
{
378380
return new LazyWebElement<>(this, context);
379381
}
380382

383+
@Contract(pure = true)
381384
public RefindingWebElement refindWhenNeeded(SearchContext context)
382385
{
383386
return new RefindingWebElement(this, context);
@@ -391,11 +394,13 @@ public WebElement findElement(SearchContext context)
391394
new NoSuchElementException("Unable to find element: " + getFindDescription(context)));
392395
}
393396

397+
@Contract(pure = true)
394398
public WebElement findElementOrNull(SearchContext context)
395399
{
396400
return findOptionalElement(context).orElse(null);
397401
}
398402

403+
@Contract(pure = true)
399404
public Optional<WebElement> findOptionalElement(SearchContext context)
400405
{
401406
List<WebElement> elements = findElements(context);
@@ -404,6 +409,7 @@ public Optional<WebElement> findOptionalElement(SearchContext context)
404409
return Optional.of(elements.get(0));
405410
}
406411

412+
@Contract(pure = true)
407413
@Override
408414
public List<WebElement> findElements(SearchContext context)
409415
{
@@ -454,11 +460,13 @@ public List<WebElement> findElements(SearchContext context)
454460
}
455461
}
456462

463+
@Contract(pure = true)
457464
public boolean existsIn(SearchContext context)
458465
{
459466
return findElementOrNull(context) != null;
460467
}
461468

469+
@Contract(pure = true)
462470
public boolean isDisplayed(SearchContext context)
463471
{
464472
WebElement element = findElementOrNull(context);
@@ -471,6 +479,7 @@ public boolean isDisplayed(SearchContext context)
471479
* @param context Search context.
472480
* @return True if there are any elements visible, false otherwise.
473481
*/
482+
@Contract(pure = true)
474483
public boolean areAnyVisible(SearchContext context)
475484
{
476485
List<WebElement> elements = findElements(context);

src/org/labkey/test/TestFileUtils.java

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
2020
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
2121
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
22+
import org.apache.commons.io.FileSystem;
2223
import org.apache.commons.io.FileUtils;
2324
import org.apache.commons.io.IOUtils;
2425
import org.apache.commons.lang3.StringUtils;
@@ -27,8 +28,6 @@
2728
import org.apache.pdfbox.Loader;
2829
import org.apache.pdfbox.pdmodel.PDDocument;
2930
import org.apache.pdfbox.text.PDFTextStripper;
30-
import org.apache.poi.xssf.streaming.SXSSFRow;
31-
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
3231
import org.bouncycastle.jce.provider.BouncyCastleProvider;
3332
import org.bouncycastle.openpgp.PGPCompressedData;
3433
import org.bouncycastle.openpgp.PGPEncryptedDataList;
@@ -41,12 +40,10 @@
4140
import org.bouncycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder;
4241
import org.bouncycastle.util.io.Streams;
4342
import org.jetbrains.annotations.NotNull;
44-
import org.labkey.serverapi.reader.Readers;
4543
import org.openqa.selenium.NotFoundException;
4644

4745
import java.io.BufferedInputStream;
4846
import java.io.BufferedOutputStream;
49-
import java.io.BufferedReader;
5047
import java.io.ByteArrayInputStream;
5148
import java.io.File;
5249
import java.io.FileInputStream;
@@ -71,6 +68,7 @@
7168
import java.util.List;
7269
import java.util.Set;
7370
import java.util.TreeSet;
71+
import java.util.regex.Pattern;
7472
import java.util.stream.Collectors;
7573
import java.util.zip.GZIPInputStream;
7674
import java.util.zip.ZipEntry;
@@ -707,34 +705,15 @@ public static byte[] decrypt(byte[] encrypted, char[] passPhrase) throws IOExcep
707705
return Streams.readAll(ld.getInputStream());
708706
}
709707

708+
private static final Pattern badChars = Pattern.compile("[\\\\:/\\[\\]?*|]");
710709

711-
public static File convertTabularToXlsx(File tabularFile, String delimiter, String sheetName, String xlsxFileName) throws IOException, PGPException
710+
/**
711+
* Determining expected file names for downloaded files that are named according to some
712+
* value that might include characters that are not legal for files
713+
* @see FileSystem#toLegalFileName(String, char)
714+
*/
715+
public static String makeLegalFileName(String candidate)
712716
{
713-
File excelFile = new File(getTestTempDir(), xlsxFileName);
714-
FileUtils.forceMkdirParent(excelFile);
715-
716-
try(SXSSFWorkbook workBook = new SXSSFWorkbook(1000); // holds 1000 rows at a time
717-
BufferedReader br = Readers.getReader(tabularFile);
718-
FileOutputStream out = new FileOutputStream(excelFile))
719-
{
720-
var sheet = workBook.createSheet(sheetName);
721-
722-
String currentLine;
723-
int rowNum=0;
724-
725-
while ((currentLine = br.readLine()) != null)
726-
{
727-
String str[] = currentLine.split(delimiter);
728-
SXSSFRow currentRow = sheet.createRow(rowNum);
729-
for (int i = 0; i < str.length; i++)
730-
{
731-
currentRow.createCell(i).setCellValue(str[i]);
732-
}
733-
rowNum++;
734-
}
735-
workBook.write(out); // flush remaining rows
736-
}
737-
738-
return excelFile;
717+
return badChars.matcher(candidate).replaceAll("_");
739718
}
740719
}

src/org/labkey/test/TestProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ public static boolean isTrialServer()
257257
return getBooleanProperty("webtest.server.trial", false);
258258
}
259259

260+
public static boolean isRemoteNameValidationEnabled()
261+
{
262+
return getBooleanProperty("webtest.remote.domain.validation", false);
263+
}
264+
260265
public static boolean isCheckerFatal()
261266
{
262267
return "true".equals(System.getProperty("webtest.checker.fatal"));

src/org/labkey/test/WebDriverWrapper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,14 @@ public long doAndMaybeWaitForPageToLoad(int msWait, Supplier<Boolean> action)
21482148
return loadTimer.elapsed().toMillis();
21492149
}
21502150

2151+
public void doAndWaitForNewWindow(Runnable action)
2152+
{
2153+
Set<String> windows = getDriver().getWindowHandles();
2154+
action.run();
2155+
switchToWindow(windows.size());
2156+
waitForDocument();
2157+
}
2158+
21512159
public long doAndWaitForWindow(Runnable action, String windowName)
21522160
{
21532161
String initialWindow = getDriver().getWindowHandle();

src/org/labkey/test/components/bootstrap/Panel.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,20 @@ public class ElementCache extends Component<?>.ElementCache
7171
protected final WebElement panelBody = Locator.byClass("panel-body").findWhenNeeded(this);
7272
}
7373

74-
public static class PanelFinder extends WebDriverComponentFinder<Panel<?>, PanelFinder>
74+
protected static abstract class AbstractPanelFinder<C extends Panel<?>, F extends AbstractPanelFinder<C, F>> extends WebDriverComponentFinder<C, F>
7575
{
76-
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "panel-default");
76+
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "panel");
7777
private String _title = null;
7878

79-
public PanelFinder(WebDriver driver)
79+
public AbstractPanelFinder(WebDriver driver)
8080
{
8181
super(driver);
8282
}
8383

84-
public PanelFinder withTitle(String title)
84+
public F withTitle(String title)
8585
{
8686
_title = title;
87-
return this;
88-
}
89-
90-
@Override
91-
protected Panel<?> construct(WebElement el, WebDriver driver)
92-
{
93-
return new PanelImpl(el, driver);
87+
return getThis();
9488
}
9589

9690
@Override
@@ -103,6 +97,26 @@ protected Locator locator()
10397
return _baseLocator;
10498
}
10599
}
100+
101+
public static class PanelFinder extends AbstractPanelFinder<Panel<?>, PanelFinder>
102+
{
103+
public PanelFinder(WebDriver driver)
104+
{
105+
super(driver);
106+
}
107+
108+
@Override
109+
protected PanelFinder getThis()
110+
{
111+
return this;
112+
}
113+
114+
@Override
115+
protected Panel<?> construct(WebElement el, WebDriver driver)
116+
{
117+
return new PanelImpl(el, driver);
118+
}
119+
}
106120
}
107121

108122
class PanelImpl extends Panel<ElementCache>

0 commit comments

Comments
 (0)