Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bot] Merge 24.11 to develop (Conflicts) #6026

Merged
merged 5 commits into from
Nov 6, 2024
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
42 changes: 23 additions & 19 deletions api/src/org/labkey/api/util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ private DateUtil()
private static final String[] SIMPLE_TIME_FORMATS_NO_AMPM = {"HH:mm:ss.SSS", "HH:mm:ss", "HH:mm"};

public static final Set<String> STANDARD_DATE_DISPLAY_FORMATS = PageFlowUtil.set(
"yyyy-MM-dd",
"yyyy-MMM-dd",
"dd-MMM-yyyy",
"dd-MMM-yy",
"ddMMMyyyy",
"ddMMMyy"
"yyyy-MM-dd",
"yyyy-MMM-dd",
"yyyy-MM",
"dd-MM-yyyy",
"dd-MMM-yyyy",
"dd-MMM-yy",
"ddMMMyyyy",
"ddMMMyy",
"MM/dd/yyyy",
"MM-dd-yyyy",
"MMMM dd yyyy"
);

public static final Set<String> STANDARD_TIME_DISPLAY_FORMATS = PageFlowUtil.set(
Expand All @@ -113,28 +118,27 @@ public record DateTimeFormat(String datePortion, @Nullable String timePortion) {

// Splits the date and time portions of a standard date-time format, where date portion is required and time portion
// is optional. Returns null if the format is non-standard, which means we can't split it.
public static DateTimeFormat splitDateTimeFormat(String dateTimeFormat)
public static DateTimeFormat splitDateTimeFormat(@NotNull String dateTimeFormat)
{
dateTimeFormat = dateTimeFormat.trim();
String datePortion = null;
String timePortion = null;

// We can't just split on whitespace because non-standard formats could: have any amount of whitespace between
// characters, put the time portion before the date portion, or even intermingle date and time characters.

for (String format : STANDARD_DATE_DISPLAY_FORMATS)
for (String format : STANDARD_TIME_DISPLAY_FORMATS)
{
if (dateTimeFormat.startsWith(format))
{
datePortion = format;
break;
}
if (dateTimeFormat.endsWith(" " + format))
timePortion = format;
}

String datePortion = dateTimeFormat;
if (timePortion != null)
datePortion = dateTimeFormat.substring(0, dateTimeFormat.length() - timePortion.length()).trim();

// If it starts with a standard date format pattern then check for standard time portion (or none)
if (datePortion != null)
if (isStandardDateDisplayFormat(datePortion))
{
String timePortion = dateTimeFormat.substring(datePortion.length()).trim();
if (timePortion.isEmpty())
if (timePortion == null || timePortion.isEmpty())
return new DateTimeFormat(datePortion, null);
else if (isStandardTimeDisplayFormat(timePortion))
return new DateTimeFormat(datePortion, timePortion);
Expand Down Expand Up @@ -2410,7 +2414,7 @@ private void testGoodDateTimeFormat(String combined, String dateFormat, String t
@Test
public void testNonStandardDateTimeFormats()
{
List<String> nonStandardDateFormats = List.of("MM/dd/yyy", "dd/MM/yyy", "yyyy.MM.dd", "MMMM dd, yyyy");
List<String> nonStandardDateFormats = List.of("MM/dd/yyy", "ddMMMyyy", "yyyy.MM.dd", "MMMM dd", "MMMM dd yy", "MMMM dd, yyyy");
List<String> nonStandardTimeFormats = List.of("kk:mm", "hh:mm aa", "hh:mm");

nonStandardDateFormats.forEach(this::testBadDateFormat);
Expand Down
22 changes: 11 additions & 11 deletions api/src/org/labkey/api/util/JunitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.AssumptionViolatedException;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
Expand Down Expand Up @@ -221,7 +222,7 @@ public static void createRaces(final Runnable runnable, final int threads, final
{
// Modules might have null sourcePath on TeamCity, so crawl for test/sampledata directories and populate
// a map the first time, then stash the map for future lookups.
String name = module.getExplodedPath().getName();
String name = module.getExplodedFileLike().getName();

synchronized (MAP_LOCK)
{
Expand Down Expand Up @@ -257,30 +258,29 @@ public static void createRaces(final Runnable runnable, final int threads, final
}

File file = new File(sampleDataDir, relativePath);
if (file.exists())
return file;

String message = "No sample data found at [" + file.getAbsolutePath() + "].";

String message = null;
if (null != module)
{
if (sampleDataDir == null || !sampleDataDir.exists())
{
Assume.assumeTrue("Module source not present for [" + module.getName() + "] module.",
!StringUtils.isBlank(module.getSourcePath()) && new File(module.getSourcePath()).exists());

message = "Sample data directory not found for [" + module.getName() + "] module.";
}
}
if (message == null && !file.exists())
{
message = "No sample data found at [" + file.getAbsolutePath() + "].";
}

if (AppProps.getInstance().isDevMode())
{
//noinspection SimplifiableJUnitAssertion
Assert.assertTrue(message, message == null);
throw new AssertionError(message);
}
else
{
Assume.assumeTrue(message + " Skipping test in production mode.", message == null);
throw new AssumptionViolatedException(message + " Skipping test in production mode.");
}

return file;
}
}
8 changes: 4 additions & 4 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
},
"dependencies": {
"@labkey/components": "5.22.0",
"@labkey/components": "5.22.2",
"@labkey/themes": "1.4.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions experiment/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion experiment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test-integration": "cross-env NODE_ENV=test jest --ci --runInBand -c test/js/jest.config.integration.js"
},
"dependencies": {
"@labkey/components": "5.22.0"
"@labkey/components": "5.22.2"
},
"devDependencies": {
"@labkey/build": "8.3.0",
Expand Down
13 changes: 9 additions & 4 deletions study/test/src/org/labkey/test/tests/study/StudyPublishTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package org.labkey.test.tests.study;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.hc.core5.http.HttpStatus;
import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.experimental.categories.Category;
import org.labkey.remoteapi.CommandException;
Expand All @@ -42,6 +44,7 @@
import org.labkey.test.pages.query.QueryMetadataEditorPage;
import org.labkey.test.pages.search.SearchResultsPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.LoggedParam;
Expand Down Expand Up @@ -912,6 +915,7 @@ private void rePublishStudy(String parentName, String newName)
verifyPublishWizardSelectedCheckboxes(StudyHelper.Panel.folderObjects,
"Categories",
"Container specific module properties",
(_containerHelper.getAllModules().contains("dataintegration") ? "ETL Definitions" : ""),
"External schema definitions",
"Folder type and active modules",
"Full-text search settings",
Expand All @@ -922,7 +926,7 @@ private void rePublishStudy(String parentName, String newName)
"Wikis and their attachments",
"File Browser Settings",
"Files",
"QC State Settings",
(_containerHelper.getAllModules().contains("samplemanagement") ? "Sample Status and " : "") + "QC State Settings",
"Sample Type Designs",
"Sample Type Data",
"Data Class Designs",
Expand Down Expand Up @@ -1070,7 +1074,7 @@ private void selectLocation(PublishLocation location)
if (location == PublishLocation.root)
{
Locator rootTreeNode = Locator.tagWithClass("a", "x-tree-node-anchor").withDescendant(Locator.tagWithText("span", "LabKey Server Projects"));
doubleClick(rootTreeNode);
doubleClick(scrollIntoView(rootTreeNode, true));
}
else if (location == PublishLocation.project)
{
Expand Down Expand Up @@ -1287,7 +1291,8 @@ private void verifyPublishWizardSelectedCheckboxes(StudyHelper.IPanel grid, Stri
int colIndex = getElementIndex(columnHeader);
Locator selectedLabelLoc = gridLoc.append(Locator.css("div.x-grid3-row-selected div.x-grid3-col-" + colIndex));
List<WebElement> selectedRows = selectedLabelLoc.findElements(getDriver());
Set<String> selectedLabels = new HashSet<>(getTexts(selectedRows));
assertEquals("Wizard has wrong checkboxes checked", new HashSet<>(Arrays.asList(expectedCheckboxes)), selectedLabels);
List<String> selectedLabels = getTexts(selectedRows);
Assertions.assertThat(selectedLabels).as("Selected " + grid.getPanelTitle() + " in study publish wizard")
.containsExactlyInAnyOrderElementsOf(Arrays.stream(expectedCheckboxes).filter(StringUtils::isNotBlank).toList());
}
}
Loading