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
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ public Optional<WebElement> optionalWarningAlert()
return elementCache().optionalWarningAlert();
}

public void setActionComment(String comment)
{
elementCache().commentInput.sendKeys(comment);
}

public void clearActionComment()
{
elementCache().commentInput.clear();
}

public boolean isCommentInputPresent()
{
return elementCache().commentInputLocator.findOptionalElement(getDriver()).isPresent();
}


/**
* Dialog that allows the user to set the genId value.
Expand Down Expand Up @@ -419,6 +434,9 @@ public final WebElement helpTarget(String divLabelText)

final Locator uniqueIdMsgLoc = Locator.tagWithClass("div", "uniqueid-msg");

public Locator.XPathLocator commentInputLocator = Locator.tagWithId("textarea", "actionComments");
public WebElement commentInput = commentInputLocator.refindWhenNeeded(getDriver());

public List<Input> parentAliases()
{
return Input.Input(Locator.name("alias"), getDriver()).findAll(propertiesPanel);
Expand Down
371 changes: 62 additions & 309 deletions src/org/labkey/test/tests/AuditLogTest.java

Large diffs are not rendered by default.

36 changes: 33 additions & 3 deletions src/org/labkey/test/tests/DomainDesignerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.labkey.test.pages.experiment.CreateSampleTypePage;
import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.AuditLogHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.TestDataGenerator;
Expand All @@ -53,6 +54,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -71,6 +73,9 @@
@Category({BVT.class})
public class DomainDesignerTest extends BaseWebDriverTest
{
private final AuditLogHelper _auditLogHelper = new AuditLogHelper(this);
final String DOMAIN_PROPERTY_LOG_NAME = "Domain property events";

@Override
protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
Expand Down Expand Up @@ -281,6 +286,13 @@ public void testInvalidLookupDomainField() throws IOException, CommandException
EditListDefinitionPage editListDefinitionPage = new EditListDefinitionPage(getDriver());
editListDefinitionPage.setName(editedListName)
.clickSave();

AuditLogHelper.DetailedAuditEventRow expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, listName, null,
"The name of the list domain 'InvalidLookUpNameList' was changed to 'InvalidLookUpNameList_edited'. The descriptor of domain InvalidLookUpNameList_edited was updated.",
"", null, null, "Name: " + listName + " > " + editedListName);
boolean pass = _auditLogHelper.validateLastDomainAuditEvents(editedListName, getProjectName(), expectedDomainEvent, Collections.emptyMap());
checker().verifyTrue("The comment logged for the list renaming was not as expected", pass);

domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "exp.materials", sampleType);
assertEquals("Look up should be updated after list renaming", "Current Folder > lists > " + editedListName, domainDesignerPage.fieldsPanel().getField("lookUpField").detailsMessage());

Expand Down Expand Up @@ -1335,18 +1347,19 @@ public void testConditionalFormat() throws Exception
public void testRegexValidator() throws Exception
{
String listName = "regexValidatorList";

String fieldNameWithReg = "favoriteSnack";
FieldDefinition.LookupInfo lookupInfo = new FieldDefinition.LookupInfo(getProjectName(), "lists", listName);
TestDataGenerator dgen = new TestDataGenerator(lookupInfo)
.withColumns(List.of(
new FieldDefinition("name", FieldDefinition.ColumnType.String),
new FieldDefinition("favoriteIceCream", FieldDefinition.ColumnType.String),
new FieldDefinition("favoriteSnack", FieldDefinition.ColumnType.String),
new FieldDefinition(fieldNameWithReg, FieldDefinition.ColumnType.String),
new FieldDefinition("size", FieldDefinition.ColumnType.Integer)));
DomainResponse createResponse = dgen.createDomain(createDefaultConnection(), "IntList", Map.of("keyName", "Key"));

DomainDesignerPage domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "lists", listName);
DomainFormPanel domainFormPanel = domainDesignerPage.fieldsPanel();
DomainFieldRow favoriteSnack = domainFormPanel.getField("favoriteSnack");
DomainFieldRow favoriteSnack = domainFormPanel.getField(fieldNameWithReg);

RegexValidatorDialog validatorDialog = favoriteSnack.clickRegexButton();
RegexValidatorPanel panel = validatorDialog.getValidationPanel();
Expand All @@ -1371,6 +1384,23 @@ public void testRegexValidator() throws Exception
assertEquals("expected error message should be on the field",
"favorite snack cannot be twizzlers, yo", specialCharsValidator.get("errorMessage"));

log("Validate that the expected rows after the update are in the log.");
String fieldOldValues = "Name=favoriteSnack&Type=String&Scale=4000&PHI=Not%20PHI&DefaultScale=Linear&Required=false&Hidden=false&MvEnabled=false&Measure=false" +
"&Dimension=false&ShownInInsert=true&ShownInDetails=true&ShownInUpdate=true&ShownInLookupView=false&RecommendedVariable=false&ExcludedFromShifting=false" +
"&Scannable=false&DefaultValueType=Editable%20default";
String fieldNewValues = fieldOldValues + "&Validator=neverTwizzlers%2C%20twizzler%20is%20not%20a%20snack%2C%20twizzler%2C%20failOnMatch%3Dtrue%2C%20favorite%20snack%20cannot%20be%20twizzlers%2C%20yo%2C%20Regular%20Expression";
AuditLogHelper.DetailedAuditEventRow fieldEvent = new AuditLogHelper.DetailedAuditEventRow(null, fieldNameWithReg, "Modified",
"The following property was updated: Validator", "", fieldOldValues, fieldNewValues, null);
AuditLogHelper.DetailedAuditEventRow expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, listName, null,
"The column(s) of domain " + listName + " were modified.",
"", null, null, null);
boolean pass = _auditLogHelper.validateLastDomainAuditEvents(listName, getProjectName(), expectedDomainEvent, Map.of(fieldNameWithReg, fieldEvent));

if(!pass)
_auditLogHelper.goToAuditEventView(DOMAIN_PROPERTY_LOG_NAME);

Assert.assertTrue("The values logged for the updating domain field regex event were not as expected. See log for details.", pass);

// this test does not verify that attempts to insert values that match will get an error
}

Expand Down
50 changes: 40 additions & 10 deletions src/org/labkey/test/tests/LinkedSchemaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import org.labkey.test.params.list.IntListDefinition;
import org.labkey.test.params.list.ListDefinition;
import org.labkey.test.params.list.VarListDefinition;
import org.labkey.test.util.APIContainerHelper;
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.AuditLogHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.SchemaHelper;
Expand All @@ -45,6 +47,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -109,6 +112,7 @@ public class LinkedSchemaTest extends BaseWebDriverTest
private static final String STUDY_FOLDER = "StudyFolder"; // Folder used to validate fix for issues 32454 & 32456
private static final String MOTHER = "Mother";
private static final String READER_USER = "reader@linkedschema.test";
private final AuditLogHelper _auditLogHelper = new AuditLogHelper(this);

public static final String LIST_NAME = "LinkedSchemaTestPeople";
public static final String LIST_DATA = "Name\tAge\tCrazy\tP\tQ\tR\tS\tT\tU\tV\tW\tX\tY\tZ\n" +
Expand Down Expand Up @@ -426,7 +430,7 @@ void deleteLinkedSchema()
}

@Test
public void lookupTest()
public void lookupTest() throws CommandException
{
String sourceContainerPath = "/" + getProjectName() + "/" + SOURCE_FOLDER;
_schemaHelper.createLinkedSchema(getProjectName() + "/" + TARGET_FOLDER, "BasicLinkedSchema", sourceContainerPath, null, "lists", "NIMHDemographics,NIMHPortions", null);
Expand All @@ -441,11 +445,23 @@ public void lookupTest()
//Make sure that the lookup columns propagated properly into the linked schema
assertLookupsWorking(TARGET_FOLDER, "BasicLinkedSchema", "NIMHDemographics", true, "Mother", "Father");

String sourceFolderId = ((APIContainerHelper) _containerHelper).getContainerId(getProjectName() + "/" + SOURCE_FOLDER);
String otherFolderId = ((APIContainerHelper) _containerHelper).getContainerId(getProjectName() + "/" + OTHER_FOLDER);

// Linked schemas disallow lookups to other folders outside of the current folder.
//Change the Mother column lookup to point to the other folder, then ensure that the mother lookup is no longer propagating
changelistLookup(SOURCE_FOLDER, "NIMHDemographics", MOTHER,
String fieldOldValues = "Name=Mother&Label=Mother&Type=Integer&PHI=Not%20PHI&DefaultScale=Linear&Required=false&Hidden=false&MvEnabled=false&Measure=false&Dimension=false" +
"&ShownInInsert=true&ShownInDetails=true&ShownInUpdate=true&ShownInLookupView=false&RecommendedVariable=false&ExcludedFromShifting=false&Scannable=false" +
"&Lookup=%7B%22queryName%22%3A%22NIMHDemographics%22%2C%22schemaName%22%3A%22lists%22%7D";
String fieldUpdateValues = "Name=Mother&Label=Mother&Type=Integer&PHI=Not%20PHI&DefaultScale=Linear&Required=false&Hidden=false&MvEnabled=false&Measure=false&Dimension=false" +
"&ShownInInsert=true&ShownInDetails=true&ShownInUpdate=true&ShownInLookupView=false&RecommendedVariable=false&ExcludedFromShifting=false&Scannable=false" +
"&Lookup=%7B%22queryName%22%3A%22NIMHDemographics%22%2C%22schemaName%22%3A%22lists%22%2C%22containerId%22%3A%22" +
otherFolderId + "%22%7D";

changelistLookup(
new FieldDefinition.LookupInfo("/" + PROJECT_NAME + "/" + OTHER_FOLDER, "lists", "NIMHDemographics")
.setTableType(FieldDefinition.ColumnType.Integer));
.setTableType(FieldDefinition.ColumnType.Integer),
fieldOldValues, fieldUpdateValues);
assertLookupsWorking(TARGET_FOLDER, "BasicLinkedSchema", "NIMHDemographics", true, "Father");
assertLookupsWorking(TARGET_FOLDER, "BasicLinkedSchema", "NIMHDemographics", false, "Mother");

Expand All @@ -457,10 +473,14 @@ public void lookupTest()
assertLookupsWorking(TARGET_FOLDER, "QueryLinkedSchema", "QueryOverLookup", true, "Father");
assertLookupsWorking(TARGET_FOLDER, "QueryLinkedSchema", "QueryOverLookup", false, "Mother");

String fieldUpdateValues2 = "Name=Mother&Label=Mother&Type=Integer&PHI=Not%20PHI&DefaultScale=Linear&Required=false&Hidden=false&MvEnabled=false&Measure=false&Dimension=false&ShownInInsert=true" +
"&ShownInDetails=true&ShownInUpdate=true&ShownInLookupView=false&RecommendedVariable=false&ExcludedFromShifting=false&Scannable=false&Lookup=%7B%22queryName%22%3A%22QueryOverLookup%22%2C%22schemaName%22%3A%22lists%22%2C%22containerId%22%3A%22" +
sourceFolderId + "%22%7D";
//Change the Mother column lookup to point to the query, and then make sure that the table has lookups appropriately.
changelistLookup(SOURCE_FOLDER, "NIMHDemographics", MOTHER,
changelistLookup(
new FieldDefinition.LookupInfo("/" + PROJECT_NAME + "/" + SOURCE_FOLDER, "lists", "QueryOverLookup")
.setTableType(FieldDefinition.ColumnType.Integer));
.setTableType(FieldDefinition.ColumnType.Integer),
fieldUpdateValues, fieldUpdateValues2);
assertLookupsWorking(TARGET_FOLDER, "QueryLinkedSchema", "NIMHDemographics", true, "Mother", "Father");
}

Expand Down Expand Up @@ -923,7 +943,7 @@ public void testAuditTableLinkedSchema()

goToSchemaBrowser();
table = viewQueryData(linkedSchemaName, "DomainAuditEvent");
checker().verifyEquals("Incorrect number of rows in DomainAuditEvent", 33, table.getDataRowCount());
checker().verifyEquals("Incorrect number of rows in DomainAuditEvent", 23, table.getDataRowCount());
}

protected void goToSchemaBrowserTable(String schemaName, String tableName)
Expand Down Expand Up @@ -991,16 +1011,26 @@ protected void assertLookupsWorking(String sourceFolder, String schemaName, Stri
}
}

protected void changelistLookup(String sourceFolder, String tableName, String fieldName, FieldDefinition.LookupInfo info)
protected void changelistLookup(FieldDefinition.LookupInfo info, String fieldOldValues, String fieldUpdateValues)
{
clickFolder(sourceFolder);
clickFolder(LinkedSchemaTest.SOURCE_FOLDER);

goToManageLists();

EditListDefinitionPage listDefinitionPage = _listHelper.goToEditDesign(tableName);
EditListDefinitionPage listDefinitionPage = _listHelper.goToEditDesign("NIMHDemographics");
listDefinitionPage.getFieldsPanel()
.getField(fieldName).setLookup(info);
.getField(LinkedSchemaTest.MOTHER).setLookup(info);
listDefinitionPage.clickSave();


log("Validate domain and domain property audit log.");
AuditLogHelper.DetailedAuditEventRow fieldEvent = new AuditLogHelper.DetailedAuditEventRow(null, LinkedSchemaTest.MOTHER, "Modified",
"The following property was updated: Lookup", "", fieldOldValues, fieldUpdateValues, null);
AuditLogHelper.DetailedAuditEventRow expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, "NIMHDemographics", null,
"The column(s) of domain " + "NIMHDemographics" + " were modified.",
"", null, null, null);
boolean pass = _auditLogHelper.validateLastDomainAuditEvents("NIMHDemographics", getProjectName(), expectedDomainEvent, Map.of(LinkedSchemaTest.MOTHER, fieldEvent));
checker().verifyTrue("Domain audit long not as expected after changing lookup expected", pass);
}

protected void createLinkedSchemaQuery(String sourceFolder, String schemaName, String queryName, String tableName)
Expand Down
27 changes: 22 additions & 5 deletions src/org/labkey/test/tests/SampleTypeNameExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.labkey.test.pages.experiment.UpdateSampleTypePage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.AuditLogHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.EscapeUtil;
import org.labkey.test.util.PortalHelper;
Expand Down Expand Up @@ -82,6 +83,8 @@ public class SampleTypeNameExpressionTest extends BaseWebDriverTest

private static final File PARENT_EXCEL = TestFileUtils.getSampleData("samples/ParentSamples.xlsx");

protected final AuditLogHelper _auditLogHelper = new AuditLogHelper(this);

@Override
public List<String> getAssociatedModules()
{
Expand Down Expand Up @@ -1283,6 +1286,13 @@ public void testSetAndResetOfGenId()
idDialog.setGenId(Integer.toString(nextGenId));
idDialog.dismiss("Update");

// check audit log
AuditLogHelper.DetailedAuditEventRow expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, sampleType, null,
"The genId for domain Test_Set_GenId has been updated to " + (nextGenId - 1) + ".", null, null,
null, null);
boolean pass = _auditLogHelper.validateLastDomainAuditEvents(sampleType, getProjectName(), expectedDomainEvent, null);
checker().verifyTrue("Result Domain event not as expected after updating genId", pass);

log("Validate that the banner has been updated.");

checker()
Expand Down Expand Up @@ -1335,17 +1345,17 @@ public void testSetAndResetOfGenId()
waitFor(updatePage::isResetGenIdVisible,
"The 'Reset GenId' button should now be visible if the sample type is empty. Fatal error.", 500);

ModalDialog deleteDialog = updatePage.clickResetGenId();
ModalDialog genIdDialog = updatePage.clickResetGenId();

String expectedMsg = String.format("The current genId is at %d. Resetting will reset genId back to 1 and cannot be undone.", nextGenId);

checker()
.withScreenshot("Reset_GenId_Dialog_Error")
.verifyEquals("Message in the reset confirm dialog is not as expected.",
expectedMsg, deleteDialog.getBodyText());
expectedMsg, genIdDialog.getBodyText());

log("Click 'Cancel' and verify banner/genId does not change.");
deleteDialog.dismiss("Cancel");
genIdDialog.dismiss("Cancel");

checker()
.withScreenshot("Reset_GenId_Cancel_Error")
Expand All @@ -1354,8 +1364,15 @@ public void testSetAndResetOfGenId()

log("Click 'Rest GenId' again and this time reset the genId.");

deleteDialog = updatePage.clickResetGenId();
deleteDialog.dismiss("Reset");
genIdDialog = updatePage.clickResetGenId();
genIdDialog.dismiss("Reset");

expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, sampleType, null,
"The genId for domain " + sampleType + " has been updated to 0.", null, null,
null, null);
pass = _auditLogHelper.validateLastDomainAuditEvents(sampleType, getProjectName(), expectedDomainEvent, null);
checker().verifyTrue("Result Domain event not as expected after resetting genId", pass);


nextGenId = 1;
checker()
Expand Down
Loading