Skip to content

Commit 5f14c73

Browse files
Merge 25.7 to 25.8
2 parents bbf9075 + 637dc78 commit 5f14c73

3 files changed

Lines changed: 72 additions & 7 deletions

File tree

src/org/labkey/test/components/Component.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.labkey.test.components;
1717

1818
import org.apache.commons.lang3.NotImplementedException;
19+
import org.jetbrains.annotations.NotNull;
1920
import org.labkey.test.Locator;
2021
import org.labkey.test.selenium.RefindingWebElement;
2122
import org.labkey.test.util.TestLogger;
@@ -27,6 +28,7 @@
2728

2829
import java.util.ArrayList;
2930
import java.util.List;
31+
import java.util.Objects;
3032
import java.util.Optional;
3133
import java.util.function.Function;
3234

@@ -43,13 +45,13 @@ public String toString()
4345
}
4446

4547
@Override
46-
public WebElement findElement(By by)
48+
public @NotNull WebElement findElement(@NotNull By by)
4749
{
4850
return getComponentElement().findElement(by);
4951
}
5052

5153
@Override
52-
public List<WebElement> findElements(By by)
54+
public @NotNull List<WebElement> findElements(@NotNull By by)
5355
{
5456
return getComponentElement().findElements(by);
5557
}
@@ -69,8 +71,9 @@ protected EC elementCache()
6971
// Pass if element doesn't exist. Might be checking if component is visible.
7072
}
7173

72-
_elementCache = newElementCache();
74+
_elementCache = Objects.requireNonNull(newElementCache());
7375
waitForReady();
76+
Objects.requireNonNull(_elementCache, "waitForReady() cleared the element cache");
7477
}
7578
return _elementCache;
7679
}
@@ -103,13 +106,13 @@ protected ElementCache()
103106
}
104107

105108
@Override
106-
public List<WebElement> findElements(By by)
109+
public @NotNull List<WebElement> findElements(@NotNull By by)
107110
{
108111
return getComponentElement().findElements(by);
109112
}
110113

111114
@Override
112-
public WebElement findElement(By by)
115+
public @NotNull WebElement findElement(@NotNull By by)
113116
{
114117
return getComponentElement().findElement(by);
115118
}

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

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import org.labkey.test.TestTimeoutException;
2929
import org.labkey.test.WebTestHelper;
3030
import org.labkey.test.categories.Daily;
31+
import org.labkey.test.components.list.ManageListsGrid;
32+
import org.labkey.test.pages.ImportDataPage;
33+
import org.labkey.test.pages.list.BeginPage;
3134
import org.labkey.test.pages.list.EditListDefinitionPage;
3235
import org.labkey.test.params.FieldDefinition;
3336
import org.labkey.test.params.FieldDefinition.ColumnType;
@@ -36,6 +39,7 @@
3639
import org.labkey.test.util.DomainUtils;
3740
import org.labkey.test.util.ExcelHelper;
3841
import org.labkey.test.util.TestDataGenerator;
42+
import org.labkey.test.util.data.TestDataUtils;
3943
import org.openqa.selenium.By;
4044
import org.openqa.selenium.support.ui.ExpectedConditions;
4145

@@ -45,6 +49,7 @@
4549
import java.util.HashMap;
4650
import java.util.List;
4751
import java.util.Map;
52+
import java.util.NoSuchElementException;
4853

4954
import static org.junit.Assert.assertEquals;
5055
import static org.junit.Assert.assertTrue;
@@ -55,6 +60,10 @@
5560
@BaseWebDriverTest.ClassTimeout(minutes = 5)
5661
public class InlineImagesListTest extends BaseWebDriverTest
5762
{
63+
64+
private final static String PROJECT_NAME = "Inline Images List Test Project";
65+
private final static String IMPORT_PROJECT_NAME = "Inline Images List Import Test Project";
66+
5867
protected final static String LIST_NAME = TestDataGenerator.randomDomainName("InlineImagesList", DomainUtils.DomainKind.IntList);
5968
// list key name has a smaller max length than other field names, so we use a constant numEndChars and exclude the repeat and all chars placeholders
6069
protected final static String LIST_KEY_NAME = TestDataGenerator.randomFieldName("Key" + ALL_CHARS_PLACEHOLDER, 0, 5, "" + ALL_CHARS_PLACEHOLDER + REPEAT_PLACEHOLDER, DomainUtils.DomainKind.IntList);
@@ -103,7 +112,7 @@ public List<String> getAssociatedModules()
103112
@Override
104113
protected String getProjectName()
105114
{
106-
return "InlineImagesListTestProject";
115+
return PROJECT_NAME;
107116
}
108117

109118
@Override
@@ -115,7 +124,8 @@ protected BrowserType bestBrowser()
115124
@Override
116125
public void doCleanup(boolean afterTest) throws TestTimeoutException
117126
{
118-
_containerHelper.deleteProject(getProjectName(), afterTest);
127+
_containerHelper.deleteProject(PROJECT_NAME, afterTest);
128+
_containerHelper.deleteProject(IMPORT_PROJECT_NAME, afterTest);
119129
}
120130

121131
@Before
@@ -331,5 +341,51 @@ public final void testList() throws Exception
331341
assertTrue("Height of row 2 not in expected range (" + ROW_HEIGHT_SMALL_LBOUND + " to " + ROW_HEIGHT_SMALL_UBOUND + "). Actual height: " + sheet.getRow(2).getHeight(), (sheet.getRow(2).getHeight() > ROW_HEIGHT_SMALL_LBOUND) && (sheet.getRow(2).getHeight() < ROW_HEIGHT_SMALL_UBOUND));
332342
assertTrue("Height of row 3 not in expected range (" + ROW_HEIGHT_TEXT_LBOUND + " to " + ROW_HEIGHT_TEXT_UBOUND + "). Actual height: " + sheet.getRow(3).getHeight(), (sheet.getRow(3).getHeight() > ROW_HEIGHT_TEXT_LBOUND) && (sheet.getRow(3).getHeight() < ROW_HEIGHT_TEXT_UBOUND));
333343
}
344+
345+
log("Verify list archive export/import can round trip attachment successfully");
346+
ManageListsGrid listsGrid = BeginPage.beginAt(this, getProjectName()).getGrid();
347+
listsGrid.checkAllOnPage();
348+
File listArchive = listsGrid.exportSelectedLists();
349+
350+
_containerHelper.createProject(IMPORT_PROJECT_NAME);
351+
352+
BeginPage.beginAt(this, IMPORT_PROJECT_NAME).importListArchive(listArchive);
353+
_listHelper.goToList(LIST_NAME);
354+
355+
// Validate that list is imported as expected with attachments
356+
assertElementPresent("Did not find the expected number of icons for images for " + LRG_PNG_FILE.getName(), Locator.xpath("//img[contains(@title, '" + LRG_PNG_FILE.getName() + "')]"), 1);
357+
assertElementPresent("Did not find the expected number of icons for images for " + JPG01_FILE.getName(), Locator.xpath("//img[contains(@title, '" + JPG01_FILE.getName() + "')]"), 1);
358+
assertElementPresent("Did not find the expected number of icons for images for " + PDF_FILE.getName(), Locator.xpath("//img[contains(@src, 'pdf.gif')]"), 1);
359+
assertElementPresent("Did not find the expected text for " + PDF_FILE.getName(), Locator.xpath("//a[contains(text(), '" + PDF_FILE.getName() + "')]"), 1);
360+
361+
// Issue 53498: reject string attachment values for import
362+
ImportDataPage listImportPage = _listHelper.clickImportData();
363+
importFilePathError(listImportPage, "5", "absent.txt");
364+
importFilePathError(listImportPage, "5", PDF_FILE.getName());
365+
listImportPage.setCopyPasteMerge(false, true);
366+
importFilePathError(listImportPage, "1", "absent.txt");
367+
importFilePathError(listImportPage, "1", PDF_FILE.getName());
368+
listImportPage.setCopyPasteMerge(true, true);
369+
importFilePathError(listImportPage, "1", "absent.txt");
370+
importFilePathError(listImportPage, "1", PDF_FILE.getName());
371+
importFilePathError(listImportPage, "5", PDF_FILE.getName());
372+
}
373+
374+
private void importFilePathError(ImportDataPage listImportPage, String key, String attachmentValue)
375+
{
376+
String pasteData = TestDataUtils.tsvStringFromRowMaps(List.of(Map.of(LIST_KEY_NAME, key, LIST_ATTACHMENT01_NAME, attachmentValue)),
377+
List.of(LIST_KEY_NAME, LIST_ATTACHMENT01_NAME), true);
378+
log(pasteData);
379+
listImportPage.setText(pasteData);
380+
listImportPage.submitExpectingError();
381+
try
382+
{
383+
String expectedError = "Row 1: Can't upload '" + attachmentValue + "' to field " + LIST_ATTACHMENT01_NAME + " with type Attachment.";
384+
checker().withScreenshot("import_error").verifyTrue("Invalid attachment error not as expected", isElementPresent(Locator.tagWithClass("div", "labkey-error").withText(expectedError)));
385+
}
386+
catch(NoSuchElementException nse)
387+
{
388+
checker().error("Invalid attachment error not present.");
389+
}
334390
}
335391
}

src/org/labkey/test/tests/filecontent/FileContentUploadTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ public void testCalculateFileRootSize() throws Exception
353353
{
354354
String calculateFileRootSizeTask = "Calculate file root sizes";
355355
goToAdminConsole().clickSystemMaintenance().runMaintenanceTask(calculateFileRootSizeTask);
356+
356357
Integer initialFileRootSize = getFileRootSize();
357358

359+
switchToMainWindow();
360+
358361
goToProjectHome();
359362
File testFile = TestFileUtils.getSampleData("fileTypes/tsv_sample.tsv");
360363

@@ -363,6 +366,9 @@ public void testCalculateFileRootSize() throws Exception
363366

364367
goToAdminConsole().clickSystemMaintenance().runMaintenanceTask(calculateFileRootSizeTask);
365368
Integer finalFileRootSize = getFileRootSize();
369+
370+
switchToMainWindow();
371+
366372
if (!checker().wrapAssertion(() -> Assertions.assertThat(finalFileRootSize)
367373
.as("Crawled file root size").isGreaterThan(initialFileRootSize)))
368374
{

0 commit comments

Comments
 (0)