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
16 changes: 16 additions & 0 deletions modules/simpletest/resources/queries/lists/People.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,26 @@ if (extraContext)

var LABKEY = require("labkey");

// Issue 52098 - do custom parsing to validate trigger script gets a chance to do type conversion
function stripPrefix(row)
{
if (row.Age && row.Age.toString().indexOf("RemoveMe") === 0)
{
row.Age = row.Age.substring("RemoveMe".length);
}
if (row.FavoriteDateTime && row.FavoriteDateTime.toString().indexOf("RemoveMe") === 0)
{
row.FavoriteDateTime = row.FavoriteDateTime.substring("RemoveMe".length);
}
}

function beforeInsert(row, errors)
{
// Test row map is case-insensitive
if (row.Name != row.nAmE)
throw new Error("beforeInsert row properties must be case-insensitive.");

stripPrefix(row);

// var result = LABKEY.Query.deleteRows({
// schemaName: "lists",
Expand All @@ -42,6 +56,8 @@ function beforeUpdate(row, oldRow, errors)
// Test oldRow map is case-insensitive
if (oldRow.Name != oldRow.nAmE)
throw new Error("beforeUpdate oldRow properties must be case-insensitive.");

stripPrefix(row);
}

function afterUpdate(row, oldRow, errors)
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public void checkErrors()
else if (currentError.size() == 1)
{
// Line after the ERROR usually has the exception type and error message
TestLogger.error(" " + iterator.next());
TestLogger.error(" " + line);
}
else if (line.startsWith("Caused by:"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.labkey.remoteapi.CommandException;
import org.labkey.test.BootstrapLocators;
import org.labkey.test.Locator;
import org.labkey.test.TestProperties;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.Component;
Expand Down Expand Up @@ -390,7 +391,7 @@ public void clickUpdate(boolean skipAuditEventCheck)
// check for the expected number of Data Changes in the latest audit event records
AuditLogHelper auditLogHelper = new AuditLogHelper(getWrapper(), () -> WebTestHelper.getRemoteApiConnection(false));
String auditEventName = auditLogHelper.getAuditEventNameFromURL();
if (!skipAuditEventCheck && auditEventName != null)
if (!skipAuditEventCheck && auditEventName != null && !TestProperties.isTrialServer())
{
try
{
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/components/ui/grids/DetailTableEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.labkey.remoteapi.CommandException;
import org.labkey.test.BootstrapLocators;
import org.labkey.test.Locator;
import org.labkey.test.TestProperties;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.Component;
Expand Down Expand Up @@ -511,7 +512,7 @@ public DetailDataPanel clickSave(boolean skipAuditEventCheck)
// check for the expected number of Data Changes in the latest audit event records
AuditLogHelper auditLogHelper = new AuditLogHelper(getWrapper(), () -> WebTestHelper.getRemoteApiConnection(false));
String auditEventName = auditLogHelper.getAuditEventNameFromURL();
if (!skipAuditEventCheck && auditEventName != null)
if (!skipAuditEventCheck && auditEventName != null && !TestProperties.isTrialServer())
{
try
{
Expand Down
10 changes: 10 additions & 0 deletions src/org/labkey/test/tests/SampleTypeLinkToStudyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class SampleTypeLinkToStudyTest extends BaseWebDriverTest
final static String SAMPLE_TYPE2 = "Sample type 2";
private final static String visitLabel1 = "Screening";
private final static String visitLabel2 = "Baseline";
private static final String READER_USER = "reader_user@user.test";

protected DateTimeFormatter _dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
protected String now = LocalDateTime.now().format(_dateTimeFormatter);
Expand All @@ -71,6 +72,7 @@ private void doSetup()
_studyHelper.startCreateStudy()
.setTimepointType(StudyHelper.TimepointType.VISIT)
.createStudy();
createUserWithPermissions(READER_USER, VISIT_BASED_STUDY, "Reader");

_containerHelper.createProject(DATE_BASED_STUDY, "Study");
_studyHelper.startCreateStudy()
Expand Down Expand Up @@ -138,6 +140,13 @@ public void testLinkToStudy()
checker().verifyEquals("Incorrect Participant ID's", Arrays.asList("P3", "P4"), table.getColumnDataAsText("ParticipantId"));
checker().verifyEquals("Incorrect category for the dataset(Uncategorized case)", " ", getCategory(VISIT_BASED_STUDY, SAMPLE_TYPE1));

// issue 53194
impersonate(READER_USER);
log("Verifying the linked sample type in study");
goToProjectHome(VISIT_BASED_STUDY);
clickAndWait(Locator.linkWithText(SAMPLE_TYPE1));
stopImpersonating();

log("Verifying log entries");
goToProjectHome(SAMPLE_TYPE_PROJECT);
clickAndWait(Locator.linkWithText(SAMPLE_TYPE1));
Expand Down Expand Up @@ -852,6 +861,7 @@ public List<String> getAssociatedModules()
@Override
protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
_userHelper.deleteUsers(false, READER_USER);
_containerHelper.deleteProject(SAMPLE_TYPE_PROJECT, afterTest);
_containerHelper.deleteProject(VISIT_BASED_STUDY, afterTest);
_containerHelper.deleteProject(DATE_BASED_STUDY, afterTest);
Expand Down
38 changes: 36 additions & 2 deletions src/org/labkey/test/tests/TriggerScriptTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class TriggerScriptTest extends BaseWebDriverTest

private static final String COMMENTS_FIELD = "Comments";
private static final String COUNTRY_FIELD = "Country";
public static final String PEOPLE_LIST_NAME = "People";

protected final PortalHelper _portalHelper = new PortalHelper(this);

Expand Down Expand Up @@ -170,6 +171,7 @@ public static void projectSetup()
init.doSetup();
}


protected void doSetup()
{
_containerHelper.createProject(getProjectName(), null);
Expand All @@ -187,10 +189,11 @@ protected void doSetup()

_listHelper.createList(getProjectName(), LIST_NAME, "Key", columns);

log("Create list in subfolder to prevent query validation failure");
_listHelper.createList(getProjectName(), "People", "Key",
log("Create the People list");
_listHelper.createList(getProjectName(), PEOPLE_LIST_NAME, "Key",
new FieldDefinition("Name", ColumnType.String).setDescription("Name"),
new FieldDefinition("Age", ColumnType.Integer).setDescription("Age"),
new FieldDefinition("FavoriteDateTime", ColumnType.DateAndTime).setDescription("Favorite date time. Who doesn't have one?"),
new FieldDefinition("Crazy", ColumnType.Boolean).setDescription("Crazy?"));

importFolderFromZip(TestFileUtils.getSampleData("studies/LabkeyDemoStudy.zip"));
Expand Down Expand Up @@ -300,7 +303,38 @@ public void testListImportTriggers()
cleanUpListRows();
}

/** Issue 52098 - ensure trigger scripts have a chance to do custom type conversion with the incoming row */
@Test
public void testListAPITriggerTypeConversion() throws Exception
{
Connection cn = WebTestHelper.getRemoteApiConnection();

// Insert a row with a value that can only be handled by the trigger script to make sure it gets a chance
// to do the conversion. People.js should strip the "RemoveMe" prefix from Age and FavoriteDateTime
InsertRowsCommand insCmd = new InsertRowsCommand(LIST_SCHEMA, PEOPLE_LIST_NAME);
insCmd.addRow(Map.of("Name", "Jimbo", "Age", "RemoveMe25", "FavoriteDateTime", "RemoveMe2025-06-11 11:42", "Crazy", "true"));
SaveRowsResponse insResp = insCmd.execute(cn, getProjectName());
List<Map<String, Object>> insertedRows = insResp.getRows();
Assert.assertEquals(1, insertedRows.size());

Map<String, Object> insertedRow = insertedRows.get(0);
Assert.assertEquals("Jimbo", insertedRow.get("Name"));
Assert.assertEquals(25, insertedRow.get("Age"));
Assert.assertEquals("2025-06-11 11:42:00.000", insertedRow.get("FavoriteDateTime"));

// Validate update too
UpdateRowsCommand upCmd = new UpdateRowsCommand(LIST_SCHEMA, PEOPLE_LIST_NAME);
insertedRow.put("Age", "RemoveMe26");
upCmd.addRow(insertedRow);
SaveRowsResponse upResp = upCmd.execute(cn, getProjectName());
List<Map<String, Object>> updatedRows = upResp.getRows();
Assert.assertEquals(1, updatedRows.size());

Map<String, Object> updatedRow = updatedRows.get(0);
Assert.assertEquals(26, updatedRow.get("Age"));
}

@Test
public void testListAPITriggers() throws Exception
{
String ssn1 = "111111112";
Expand Down