Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions src/org/labkey/test/components/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.labkey.test.components;

import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.NotNull;
import org.labkey.test.Locator;
import org.labkey.test.selenium.RefindingWebElement;
import org.labkey.test.util.TestLogger;
Expand All @@ -27,6 +28,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;

Expand All @@ -43,13 +45,13 @@ public String toString()
}

@Override
public WebElement findElement(By by)
public @NotNull WebElement findElement(@NotNull By by)
{
return getComponentElement().findElement(by);
}

@Override
public List<WebElement> findElements(By by)
public @NotNull List<WebElement> findElements(@NotNull By by)
{
return getComponentElement().findElements(by);
}
Expand All @@ -69,8 +71,9 @@ protected EC elementCache()
// Pass if element doesn't exist. Might be checking if component is visible.
}

_elementCache = newElementCache();
_elementCache = Objects.requireNonNull(newElementCache());
waitForReady();
Objects.requireNonNull(_elementCache, "waitForReady() cleared the element cache");
}
return _elementCache;
}
Expand Down Expand Up @@ -103,13 +106,13 @@ protected ElementCache()
}

@Override
public List<WebElement> findElements(By by)
public @NotNull List<WebElement> findElements(@NotNull By by)
{
return getComponentElement().findElements(by);
}

@Override
public WebElement findElement(By by)
public @NotNull WebElement findElement(@NotNull By by)
{
return getComponentElement().findElement(by);
}
Expand Down
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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,11 @@ public void testCalculateFileRootSize() throws Exception
{
String calculateFileRootSizeTask = "Calculate file root sizes";
goToAdminConsole().clickSystemMaintenance().runMaintenanceTask(calculateFileRootSizeTask);

Integer initialFileRootSize = getFileRootSize();

switchToMainWindow();

goToProjectHome();
File testFile = TestFileUtils.getSampleData("fileTypes/tsv_sample.tsv");

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

goToAdminConsole().clickSystemMaintenance().runMaintenanceTask(calculateFileRootSizeTask);
Integer finalFileRootSize = getFileRootSize();

switchToMainWindow();

if (!checker().wrapAssertion(() -> Assertions.assertThat(finalFileRootSize)
.as("Crawled file root size").isGreaterThan(initialFileRootSize)))
{
Expand Down