Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/org/labkey/test/tests/InlineImagesListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.components.list.ManageListsGrid;
import org.labkey.test.pages.ImportDataPage;
import org.labkey.test.pages.list.BeginPage;
import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldDefinition.ColumnType;
import org.labkey.test.util.DataRegionExportHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.ExcelHelper;
import org.labkey.test.util.TestDataGenerator;
import org.labkey.test.util.data.TestDataUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;

Expand All @@ -44,6 +48,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand All @@ -52,6 +57,9 @@
@BaseWebDriverTest.ClassTimeout(minutes = 5)
public class InlineImagesListTest extends BaseWebDriverTest
{
private final static String PROJECT_NAME = "Inline Images List Test Project";
private final static String IMPORT_PROJECT_NAME = "Inline Images List Import Test Project";

protected final static String LIST_NAME = TestDataGenerator.randomDomainName("InlineImagesList");
protected final static String LIST_KEY_NAME = TestDataGenerator.randomFieldName("Key");
protected final static ColumnType LIST_KEY_TYPE = ColumnType.Integer;
Expand Down Expand Up @@ -99,7 +107,7 @@ public List<String> getAssociatedModules()
@Override
protected String getProjectName()
{
return "InlineImagesListTestProject";
return PROJECT_NAME;
}

@Override
Expand All @@ -111,7 +119,8 @@ protected BrowserType bestBrowser()
@Override
public void doCleanup(boolean afterTest) throws TestTimeoutException
{
_containerHelper.deleteProject(getProjectName(), afterTest);
_containerHelper.deleteProject(PROJECT_NAME, afterTest);
_containerHelper.deleteProject(IMPORT_PROJECT_NAME, afterTest);
}

@Before
Expand Down Expand Up @@ -327,5 +336,51 @@ public final void testList() throws Exception
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));
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));
}

log("Verify list archive export/import can round trip attachment successfully");
ManageListsGrid listsGrid = BeginPage.beginAt(this, getProjectName()).getGrid();
listsGrid.checkAllOnPage();
File listArchive = listsGrid.exportSelectedLists();

_containerHelper.createProject(IMPORT_PROJECT_NAME);

BeginPage.beginAt(this, IMPORT_PROJECT_NAME).importListArchive(listArchive);
_listHelper.goToList(LIST_NAME);

// Validate that list is imported as expected with attachments
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);
assertElementPresent("Did not find the expected number of icons for images for " + JPG01_FILE.getName(), Locator.xpath("//img[contains(@title, '" + JPG01_FILE.getName() + "')]"), 1);
assertElementPresent("Did not find the expected number of icons for images for " + PDF_FILE.getName(), Locator.xpath("//img[contains(@src, 'pdf.gif')]"), 1);
assertElementPresent("Did not find the expected text for " + PDF_FILE.getName(), Locator.xpath("//a[contains(text(), '" + PDF_FILE.getName() + "')]"), 1);

// Issue 53498: reject string attachment values for import
ImportDataPage listImportPage = _listHelper.clickImportData();
importFilePathError(listImportPage, "5", "absent.txt");
importFilePathError(listImportPage, "5", PDF_FILE.getName());
listImportPage.setCopyPasteMerge(false, true);
importFilePathError(listImportPage, "1", "absent.txt");
importFilePathError(listImportPage, "1", PDF_FILE.getName());
listImportPage.setCopyPasteMerge(true, true);
importFilePathError(listImportPage, "1", "absent.txt");
importFilePathError(listImportPage, "1", PDF_FILE.getName());
importFilePathError(listImportPage, "5", PDF_FILE.getName());
}

private void importFilePathError(ImportDataPage listImportPage, String key, String attachmentValue)
{
String pasteData = TestDataUtils.tsvStringFromRowMaps(List.of(Map.of(LIST_KEY_NAME, key, LIST_ATTACHMENT01_NAME, attachmentValue)),
List.of(LIST_KEY_NAME, LIST_ATTACHMENT01_NAME), true);
log(pasteData);
listImportPage.setText(pasteData);
listImportPage.submitExpectingError();
try
{
String expectedError = "Row 1: Can't upload '" + attachmentValue + "' to field " + LIST_ATTACHMENT01_NAME + " with type Attachment.";
checker().withScreenshot("import_error").verifyTrue("Invalid attachment error not as expected", isElementPresent(Locator.tagWithClass("div", "labkey-error").withText(expectedError)));
}
catch(NoSuchElementException nse)
{
checker().error("Invalid attachment error not present.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
checker().error("Invalid attachment error not present.");
checker().withScreenshot().error("Invalid attachment error not present.");

}
}
}