Skip to content

Commit 6b7cfe2

Browse files
committed
Fix attachment field with underscore
1 parent 15872c1 commit 6b7cfe2

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

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

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
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;
3437
import org.labkey.test.util.DataRegionExportHelper;
3538
import org.labkey.test.util.DataRegionTable;
3639
import org.labkey.test.util.ExcelHelper;
3740
import org.labkey.test.util.TestDataGenerator;
41+
import org.labkey.test.util.data.TestDataUtils;
3842
import org.openqa.selenium.By;
3943
import org.openqa.selenium.support.ui.ExpectedConditions;
4044

@@ -44,6 +48,7 @@
4448
import java.util.HashMap;
4549
import java.util.List;
4650
import java.util.Map;
51+
import java.util.NoSuchElementException;
4752

4853
import static org.junit.Assert.assertEquals;
4954
import static org.junit.Assert.assertTrue;
@@ -52,6 +57,9 @@
5257
@BaseWebDriverTest.ClassTimeout(minutes = 5)
5358
public class InlineImagesListTest extends BaseWebDriverTest
5459
{
60+
private final static String PROJECT_NAME = "InlineImagesListTestProject";
61+
private final static String IMPORT_PROJECT_NAME = "InlineImagesListImportTestProject";
62+
5563
protected final static String LIST_NAME = TestDataGenerator.randomDomainName("InlineImagesList");
5664
protected final static String LIST_KEY_NAME = TestDataGenerator.randomFieldName("Key");
5765
protected final static ColumnType LIST_KEY_TYPE = ColumnType.Integer;
@@ -99,7 +107,7 @@ public List<String> getAssociatedModules()
99107
@Override
100108
protected String getProjectName()
101109
{
102-
return "InlineImagesListTestProject";
110+
return PROJECT_NAME;
103111
}
104112

105113
@Override
@@ -111,7 +119,8 @@ protected BrowserType bestBrowser()
111119
@Override
112120
public void doCleanup(boolean afterTest) throws TestTimeoutException
113121
{
114-
_containerHelper.deleteProject(getProjectName(), afterTest);
122+
_containerHelper.deleteProject(PROJECT_NAME, afterTest);
123+
_containerHelper.deleteProject(IMPORT_PROJECT_NAME, afterTest);
115124
}
116125

117126
@Before
@@ -327,5 +336,51 @@ public final void testList() throws Exception
327336
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));
328337
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));
329338
}
339+
340+
log("Verify list archive export/import can round trip attachment successfully");
341+
ManageListsGrid listsGrid = BeginPage.beginAt(this, getProjectName()).getGrid();
342+
listsGrid.checkAllOnPage();
343+
File listArchive = listsGrid.exportSelectedLists();
344+
345+
_containerHelper.createProject(IMPORT_PROJECT_NAME);
346+
347+
BeginPage.beginAt(this, IMPORT_PROJECT_NAME).importListArchive(listArchive);
348+
_listHelper.goToList(LIST_NAME);
349+
350+
// Validate that list is imported as expected with attachments
351+
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);
352+
assertElementPresent("Did not find the expected number of icons for images for " + JPG01_FILE.getName(), Locator.xpath("//img[contains(@title, '" + JPG01_FILE.getName() + "')]"), 1);
353+
assertElementPresent("Did not find the expected number of icons for images for " + PDF_FILE.getName(), Locator.xpath("//img[contains(@src, 'pdf.gif')]"), 1);
354+
assertElementPresent("Did not find the expected text for " + PDF_FILE.getName(), Locator.xpath("//a[contains(text(), '" + PDF_FILE.getName() + "')]"), 1);
355+
356+
// Issue 53498: reject string attachment values for import
357+
ImportDataPage listImportPage = _listHelper.clickImportData();
358+
importFilePathError(listImportPage, "5", "absent.txt");
359+
importFilePathError(listImportPage, "5", PDF_FILE.getName());
360+
listImportPage.setCopyPasteMerge(false, true);
361+
importFilePathError(listImportPage, "1", "absent.txt");
362+
importFilePathError(listImportPage, "1", PDF_FILE.getName());
363+
listImportPage.setCopyPasteMerge(true, true);
364+
importFilePathError(listImportPage, "1", "absent.txt");
365+
importFilePathError(listImportPage, "1", PDF_FILE.getName());
366+
importFilePathError(listImportPage, "5", PDF_FILE.getName());
367+
}
368+
369+
private void importFilePathError(ImportDataPage listImportPage, String key, String attachmentValue)
370+
{
371+
String pasteData = TestDataUtils.tsvStringFromRowMaps(List.of(Map.of(LIST_KEY_NAME, key, LIST_ATTACHMENT01_NAME, attachmentValue)),
372+
List.of(LIST_KEY_NAME, LIST_ATTACHMENT01_NAME), true);
373+
log(pasteData);
374+
listImportPage.setText(pasteData);
375+
listImportPage.submitExpectingError();
376+
try
377+
{
378+
String expectedError = "Row 1: Can't upload '" + attachmentValue + "' to field " + LIST_ATTACHMENT01_NAME + " with type Attachment.";
379+
isElementPresent(Locator.tagWithClass("div", "labkey-error").withText(expectedError));
380+
}
381+
catch(NoSuchElementException nse)
382+
{
383+
checker().fatal().error("Invalid attachment error not present.");
384+
}
330385
}
331386
}

0 commit comments

Comments
 (0)