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
7 changes: 5 additions & 2 deletions src/org/labkey/test/pages/DatasetInsertPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
import org.apache.tika.utils.StringUtils;
import org.labkey.test.Locator;
import org.labkey.test.Locators;
import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.Map;

import static org.labkey.test.util.EscapeUtil.FORM_FIELD_PREFIX;

public class DatasetInsertPage extends InsertPage
{
public DatasetInsertPage(WebDriver driver, String datasetName)
Expand All @@ -39,7 +42,7 @@ public DatasetInsertPage(WebDriver driver)
protected void waitForReady()
{
super.waitForReady();
waitForElement(Locator.tag("*").attributeStartsWith("name", "quf_"));
waitForElement(Locator.tag("*").attributeStartsWith("name", FORM_FIELD_PREFIX));
}

public void insert(Map<String, String> values)
Expand Down Expand Up @@ -79,7 +82,7 @@ private void tryInsert(Map<String, String> values)
{
for (Map.Entry<String, String> entry : values.entrySet())
{
WebElement fieldInput = Locator.name("quf_" + entry.getKey()).findElement(getDriver());
WebElement fieldInput = Locator.name(EscapeUtil.getFormFieldName(entry.getKey())).findElement(getDriver());
String type = fieldInput.getAttribute("type");
switch (type)
{
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/pages/query/UpdateQueryRowPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.OptionSelect;
import org.labkey.test.pages.LabKeyPage;
import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -185,7 +186,7 @@ WebElement findField(String name)
{
if (!fieldMap.containsKey(name))
{
fieldMap.put(name, Locator.name("quf_" + name).findElement(this));
fieldMap.put(name, Locator.name(EscapeUtil.getFormFieldName(name)).findElement(this));
}
return fieldMap.get(name);
}
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/pages/user/UpdateUserDetailsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.html.Input;
import org.labkey.test.pages.LabKeyPage;
import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -109,7 +110,7 @@ protected Input findInput(String fieldName)
{
if (!formElements.containsKey(fieldName))
{
Input input = Input.Input(Locator.name("quf_" + fieldName), getDriver()).find();
Input input = Input.Input(Locator.name(EscapeUtil.getFormFieldName(fieldName)), getDriver()).find();
formElements.put(fieldName, input);
}
return formElements.get(fieldName);
Expand Down
13 changes: 7 additions & 6 deletions src/org/labkey/test/tests/AliquotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Specimen;
import org.labkey.test.components.html.BootstrapMenu;
import org.labkey.test.components.html.OptionSelect;
import org.labkey.test.pages.ImportDataPage;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.LogMethod;
Expand Down Expand Up @@ -274,12 +275,12 @@ private void verifyInsertingSpecimens()

// verify insert new here
DataRegionTable detail = new DataRegionTable("SpecimenDetail", this);
detail.clickInsertNewRow();
setFormElement(Locator.xpath("//input[@name='quf_GlobalUniqueId']"), "Global");
setFormElement(Locator.xpath("//input[@name='quf_VisitDescription']"), "NewVisit");
setFormElement(Locator.xpath("//input[@name='quf_SequenceNum']"), "001");
selectOptionByText(Locator.name("quf_ParticipantId"), "618005775");
clickButton("Submit");
detail.clickInsertNewRow()
.setField("GlobalUniqueId", "Global")
.setField("VisitDescription", "NewVisit")
.setField("SequenceNum", "001")
.setField("ParticipantId", OptionSelect.SelectOption.textOption("618005775"))
.submit();
assertElementNotPresent(Locator.tagWithClass("*", "labkey-error").withText());
detail.setFilter("VisitDescription", "Equals", "NewVisit");
assertTextPresent("NewVisit");
Expand Down
68 changes: 34 additions & 34 deletions src/org/labkey/test/tests/AttachmentFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.categories.Daily;
import org.labkey.test.components.DomainDesignerPage;
import org.labkey.test.components.domain.DomainFieldRow;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.admin.FileRootsManagementPage;
import org.labkey.test.pages.experiment.UpdateSampleTypePage;
import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.DataRegionTable;
Expand Down Expand Up @@ -58,14 +57,18 @@ private void doSetup()
portalHelper.addBodyWebPart("Lists");
}

@Before
public void preTest()
{
goToProjectHome();
}

@Test
public void testFileFieldInSampleType()
{
goToProjectHome();
String sampleTypeName = "Sample type with attachment";
String fieldName = "testFile";
SampleTypeHelper sampleTypeHelper = new SampleTypeHelper(this);
goToProjectHome();

log("Create a sample type with attachment field");
sampleTypeHelper.createSampleType(new SampleTypeDefinition(sampleTypeName)
Expand All @@ -76,11 +79,13 @@ public void testFileFieldInSampleType()
log("Inserting samples in sample Type");
goToProjectHome();
clickAndWait(Locator.linkWithText(sampleTypeName));
DataRegionTable samplesTable = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor();
samplesTable.clickInsertNewRow();
setFormElement(Locator.name("quf_Name"), "S1");
setFormElement(Locator.name("quf_" + fieldName), SAMPLE_FILE);
clickButton("Submit");

DataRegionTable.DataRegion(getDriver()).withName("Material")
.waitFor()
.clickInsertNewRow()
.setField("Name", "S1")
.setField(fieldName, SAMPLE_FILE)
.submit();

assertElementPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));

Expand Down Expand Up @@ -113,7 +118,7 @@ public void testFileFieldInSampleType()
fileRootsManagementPage = goToFolderManagement().goToFilesTab();
fileRootsManagementPage.useCustomFileRoot(childFileRoot).clickSave();

// verify file path display for files that's present but outside of current file root
// verify file path display for files that are present but outside the current file root
verifyUnavailableFile();

// reset file root to default
Expand All @@ -125,7 +130,7 @@ public void testFileFieldInSampleType()
clickAndWait(Locator.linkWithText(sampleTypeName));
assertElementPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));

// delete the file and verify file path that doesn't exist
// delete the file and verify the file path that doesn't exist
goToModule("FileContent");
_fileBrowserHelper.deleteFile("sampletype");
verifyUnavailableFile();
Expand All @@ -139,39 +144,35 @@ private void verifyUnavailableFile()
waitForElement(Locator.tagContainingText("td", "jpg_sample.jpg (unavailable)"));
assertElementNotPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));

// "(unavailable)" suffix is present in update view
// "(unavailable)" suffix is present in the update view
clickAndWait(Locator.tagWithText("a", "S1"));
clickAndWait(Locator.tagWithClass("a", "labkey-text-link").withText("edit"));
waitForElement(Locator.tagContainingText("div", "jpg_sample.jpg (unavailable)"));
assertElementNotPresent(Locator.tagWithAttributeContaining("img", "src", "/_icons/image.png"));

}

@Test
public void testAttachmentFieldInLists()
{
String listName = TestDataGenerator.randomDomainName("List with attachment field");
String fieldName = TestDataGenerator.randomFieldName("Test File");
goToProjectHome();
log("Creating the list");
_listHelper.createList(getProjectName(), listName, "id");

log("Adding a attachment field with Show attachment in Browser");
DomainDesignerPage domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "lists", listName);
DomainFormPanel panel = domainDesignerPage.fieldsPanel();
DomainFieldRow stringRow = panel
.addField(fieldName)
.setType(FieldDefinition.ColumnType.Attachment);
stringRow.setAttachmentBehavior("Show Attachment in Browser");
domainDesignerPage.clickFinish();
EditListDefinitionPage editPage = _listHelper.goToEditDesign(listName)
.addField(new FieldDefinition(fieldName, FieldDefinition.ColumnType.Attachment));
editPage.getFieldsPanel()
.getField(fieldName)
.setAttachmentBehavior("Show Attachment in Browser");
editPage.clickSave();

log("Insert row in list");
goToProjectHome();
clickAndWait(Locator.linkWithText(listName));
DataRegionTable listTable = new DataRegionTable("query", getDriver());
listTable.clickInsertNewRow();
setFormElement(Locator.name("quf_" + fieldName), SAMPLE_FILE);
clickButton("Submit");
_listHelper.beginAtList(getProjectName(), listName);
new DataRegionTable("query", getDriver())
.clickInsertNewRow()
.setField(fieldName, SAMPLE_FILE)
.submit();

log("Verify file opened in browser");
Locator.tagWithAttributeContaining("img", "title", SAMPLE_FILE.getName()).findElement(getDriver()).click();
Expand All @@ -181,13 +182,12 @@ public void testAttachmentFieldInLists()
switchToMainWindow();

log("Verify file is downloaded");
domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "lists", listName);
panel = domainDesignerPage.fieldsPanel();
panel.getField(fieldName).setAttachmentBehavior("Download Attachment");
domainDesignerPage.clickFinish();
editPage = _listHelper.goToEditDesign(listName);
editPage.getFieldsPanel()
.getField(fieldName)
.setAttachmentBehavior("Download Attachment");
editPage.clickSave();

goToProjectHome();
clickAndWait(Locator.linkWithText(listName));
File downloadedFile = doAndWaitForDownload(() -> Locator.tagWithAttributeContaining("img", "title", SAMPLE_FILE.getName()).findElement(getDriver()).click());
Assert.assertTrue("Downloaded file is empty", downloadedFile.length() > 0);
}
Expand Down
16 changes: 8 additions & 8 deletions src/org/labkey/test/tests/DataClassFolderExportImportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ public void testExportImportSimpleDataClass() throws Exception

clickAndWait(Locator.linkWithText(testDataClass));
DataRegionTable sourceTable = DataRegionTable.DataRegion(getDriver()).withName("query").waitFor();
for (int i=0; i<_attachments.size(); i++)
{ // for the nonce, we cannot add file attachments to an attachment column via remoteAPI
// issue https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=42191 tracks this
// until it is fixed we will have to add attachments via the UI, like this
sourceTable.clickEditRow(i);
setFormElement(Locator.input("quf_" + attachmentColumnName), _attachments.get(i));
clickButton("Submit");
for (int i = 0; i < _attachments.size(); i++)
{
// For the nonce, we cannot add file attachments to an attachment column via remoteAPI
// Issue 42191 tracks this until it is fixed we will have to add attachments via the UI
sourceTable.clickEditRow(i)
.setField(attachmentColumnName, _attachments.get(i))
.submit();
}
List<Map<String, String>> sourceRowData = sourceTable.getTableData();

Expand Down Expand Up @@ -306,7 +306,7 @@ private void setupMVIndicators(List<Map<String, String>> missingValueIndicators)
shortWait().until(ExpectedConditions.stalenessOf(deleteButton));
}

for(int index = 0; index < missingValueIndicators.size(); index++)
for (int index = 0; index < missingValueIndicators.size(); index++)
{
clickButton("Add", 0);
WebElement mvInd = Locator.css("#mvIndicatorsDiv input[name=mvIndicators]").index(index).waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/SampleTypeRemoteAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.labkey.test.util.AbstractDataRegionExportOrSignHelper;
import org.labkey.test.util.DataRegionExportHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.EscapeUtil;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.TestDataGenerator;
import org.labkey.test.util.TestDataValidator;
Expand Down Expand Up @@ -272,7 +273,7 @@ public void updateMissingValueSampleData() throws IOException, CommandException
String mvIndicatorColName = "mvStringDataMVIndicator";
materialsList.updateRow(dIndex, Map.of("mvStringData", "reallyUpdatedValue", mvIndicatorColName, "Q")); // update the underlying value but set it mv-Q
materialsList.clickEditRow(eIndex);
selectOptionByText(Locator.name("quf_"+mvIndicatorColName), ""); // clear the mv value, reveal underlying value
selectOptionByText(Locator.name(EscapeUtil.getFormFieldName(mvIndicatorColName)), ""); // clear the mv value, reveal underlying value
clickButton("Submit");

eIndex = materialsList.getRowIndex("Name", "E");
Expand Down
19 changes: 9 additions & 10 deletions src/org/labkey/test/tests/UserDetailsPermissionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.labkey.test.components.DomainDesignerPage;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.query.ExecuteQueryPage;
import org.labkey.test.pages.user.UpdateUserDetailsPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.DataRegionTable.DataRegionFinder;
Expand Down Expand Up @@ -115,20 +116,18 @@ private void doSetup()

impersonate(ADMIN_USER);
{
goToMyAccount();
clickButton("Edit");
setFormElement(Locator.name("quf_Phone"), HIDDEN_STRING);
setFormElement(Locator.name("quf_" + CUSTOM_USER_COLUMN), HIDDEN_STRING);
clickButton("Submit");
UpdateUserDetailsPage page = goToMyAccount().clickEdit();
page.setField("Phone", HIDDEN_STRING);
page.setField(CUSTOM_USER_COLUMN, HIDDEN_STRING);
page.clickSubmit();
}
stopImpersonating();
impersonate(CHECKED_USER);
{
goToMyAccount();
clickButton("Edit");
setFormElement(Locator.name("quf_Phone"), HIDDEN_STRING);
setFormElement(Locator.name("quf_" + CUSTOM_USER_COLUMN), HIDDEN_STRING);
clickButton("Submit");
UpdateUserDetailsPage page = goToMyAccount().clickEdit();
page.setField("Phone", HIDDEN_STRING);
page.setField(CUSTOM_USER_COLUMN, HIDDEN_STRING);
page.clickSubmit();
}
stopImpersonating();
}
Expand Down
20 changes: 8 additions & 12 deletions src/org/labkey/test/tests/UserTableCustomFieldUpdateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.query.UpdateRowsCommand;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
Expand All @@ -21,6 +20,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Category({Daily.class})
@BaseWebDriverTest.ClassTimeout(minutes = 3)
Expand Down Expand Up @@ -62,10 +62,7 @@ private void doSetup()
_userHelper.createUser(TEST_USER);
}

/*
Regression coverage for Issue 48185: Update of the User table clears any non-specified custom fields
*/
@Test
@Test // Issue 48185
public void testCustomFieldUpdate() throws IOException, CommandException
{
log("Extract the userId");
Expand All @@ -77,15 +74,15 @@ public void testCustomFieldUpdate() throws IOException, CommandException
goToHome();
impersonate(TEST_USER);
{
goToMyAccount();
clickButton("Edit");
setFormElement(Locator.name("quf_" + CUSTOM_FIELD1), "Value for " + CUSTOM_FIELD1);
setFormElement(Locator.name("quf_" + CUSTOM_FIELD2), "Value for " + CUSTOM_FIELD2);
clickButton("Submit");
goToMyAccount()
.clickEdit()
.setField(CUSTOM_FIELD1, "Value for " + CUSTOM_FIELD1)
.setField(CUSTOM_FIELD2, "Value for " + CUSTOM_FIELD2)
.clickSubmit();
}
stopImpersonating();

HashMap row = new HashMap<String, String>();
Map<String, Object> row = new HashMap<>();
row.put("UserId", userId);
row.put(CUSTOM_FIELD1, "Updated value for " + CUSTOM_FIELD1);

Expand All @@ -108,5 +105,4 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
_userHelper.deleteUsers(false, TEST_USER);
}

}
Loading