Skip to content

Commit

Permalink
Merge 24.12 to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Dec 9, 2024
2 parents ed9e85e + 06906e6 commit 3850d55
Show file tree
Hide file tree
Showing 15 changed files with 2,047 additions and 126 deletions.
212 changes: 150 additions & 62 deletions src/org/labkey/test/components/domain/DomainFieldRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import org.labkey.test.components.html.SelectWrapper;
import org.labkey.test.components.react.FilteringReactSelect;
import org.labkey.test.components.ui.ontology.ConceptPickerDialog;
import org.labkey.test.pages.core.admin.BaseSettingsPage.DATE_FORMAT;
import org.labkey.test.pages.core.admin.BaseSettingsPage.TIME_FORMAT;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.LabKeyExpectedConditions;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -146,12 +147,8 @@ public DomainFieldRow setType(FieldDefinition.ColumnType columnType, boolean con
public ModalDialog setTypeWithDialog(FieldDefinition.ColumnType columnType)
{
elementCache().fieldTypeSelectInput.selectByVisibleText(columnType.getLabel());

ModalDialog confirmDialog = new ModalDialog.ModalDialogFinder(getDriver())
return new ModalDialog.ModalDialogFinder(getDriver())
.withTitle("Confirm Data Type Change").timeout(1000).waitFor();

return confirmDialog;

}

public boolean getRequiredField()
Expand Down Expand Up @@ -412,29 +409,19 @@ public DomainFieldRow setFormat(String formatString, @Nullable String dataType)
{
expand();

if (!StringUtils.isEmpty(dataType))

if (FieldDefinition.ColumnType.DateAndTime.getRangeURI().equals(dataType) ||
FieldDefinition.ColumnType.Date.getRangeURI().equals(dataType) ||
(FieldDefinition.ColumnType.Time.getRangeURI().equals(dataType)))
{
if (FieldDefinition.ColumnType.DateAndTime.getRangeURI().equals(dataType))
{
setDateTimeFormat(formatString);
return this;
}
if (FieldDefinition.ColumnType.Date.getRangeURI().equals(dataType))
{
setDateFormat(formatString);
return this;
}
if (FieldDefinition.ColumnType.Time.getRangeURI().equals(dataType))
{
setTimeFormat(formatString);
return this;
}
throw new UnsupportedOperationException("Setting the format for Date, Time or DateTime fields not supported in this method.");
}
if(elementCache().formatInput.getComponentElement().isDisplayed())

if (elementCache().formatInput.getComponentElement().isDisplayed())
{
elementCache().formatInput.setValue(formatString);
}
else if(elementCache().charScaleInput.getComponentElement().isDisplayed())
else if (elementCache().charScaleInput.getComponentElement().isDisplayed())
{
// Formatting of Boolean types use the scale input.
elementCache().charScaleInput.setValue(formatString);
Expand Down Expand Up @@ -1303,67 +1290,93 @@ public boolean isDateTimeInherited()
return elementCache().dateTimeInheritedCheckbox.get();
}

public String getDateTimeFormatDate()
public DomainFieldRow setDateTimeFormat(DATE_FORMAT date, TIME_FORMAT time)
{
return getFormatWithoutExample(elementCache().dateTimeFormatDateSelect.getValue());
setDateTimeFormat(date);
setDateTimeFormat(time);
return this;
}

public DomainFieldRow setDateTimeFormatDate(String dateFormat)
public DomainFieldRow setDateTimeFormat(DATE_FORMAT dateFormat)
{
expand();
if (isDateTimeInherited())
setDateTimeInherited(false);
elementCache().dateTimeFormatDateSelect.typeAheadSelect(dateFormat + " (");

String txt;

if (dateFormat.equals(DATE_FORMAT.DATETIME))
{
txt = dateFormat.toString();
}
else
{
txt = dateFormat + " (";
}

elementCache().dateTimeFormatDateSelect.typeAheadSelect(txt);
return this;
}

public DomainFieldRow setDateTimeFormatTime(String timeFormat)
public DomainFieldRow setDateTimeFormat(TIME_FORMAT timeFormat)
{
expand();
if (isDateTimeInherited())
setDateTimeInherited(false);
elementCache().dateTimeFormatTimeSelect.typeAheadSelect(timeFormat + " (");
elementCache().dateTimeFormatTimeSelect.typeAheadSelect(TIME_FORMAT.none.equals(timeFormat) ? timeFormat.toString() : timeFormat + " (");
return this;
}

public String getDateTimeFormatTime()
public String getDateTimeFormatDate()
{
return getFormatWithoutExample(elementCache().dateTimeFormatTimeSelect.getValue());
String formatValue;

if(elementCache().dateTimeFormatDateSelect.isInteractive())
{
formatValue = getFormatWithoutExample(elementCache().dateTimeFormatDateSelect.getValue());
}
else
{
formatValue = getFormatWithoutExample(elementCache().disabledDateTimeDateFormat.getText());
}

return formatValue;
}

public String getDateTimeFormat()
public boolean isDateTimeFormatDateEnabled()
{
String date = getDateTimeFormatDate();
String time = getDateTimeFormatTime();
if ("<none>".equals(time))
time = null;
if (StringUtils.isEmpty(time))
return date;

return date + " " + time;
return elementCache().dateTimeFormatDateSelect.isInteractive();
}

public DomainFieldRow setDateTimeFormat(String dateTime)
public String getDateTimeFormatTime()
{
expand();
if (isDateTimeInherited())
setDateTimeInherited(false);
String formatValue;

if(elementCache().dateTimeFormatTimeSelect.isInteractive())
{
formatValue = getFormatWithoutExample(elementCache().dateTimeFormatTimeSelect.getValue());
}
else
{
formatValue = getFormatWithoutExample(elementCache().disabledDateTimeTimeFormat.getText());
}

String[] parts = dateTime.split("\\s+", 2);
if (parts.length == 2)
return setDateTimeFormat(parts[0], parts[1]);
return setDateTimeFormat(parts[0], "<none>");
return formatValue;
}

public DomainFieldRow setDateTimeFormat(String date, String time)
public boolean isDateTimeFormatTimeEnabled()
{
expand();
if (isDateTimeInherited())
setDateTimeInherited(false);
return elementCache().dateTimeFormatTimeSelect.isInteractive();
}

elementCache().dateTimeFormatDateSelect.typeAheadSelect(date + " (");
elementCache().dateTimeFormatTimeSelect.typeAheadSelect("<none>".equals(time) ? time : time + " (");
return this;
public String getDateTimeFormat()
{
String date = getDateTimeFormatDate();
String time = getDateTimeFormatTime();
if (TIME_FORMAT.none.toString().equals(time) || StringUtils.isEmpty(time))
return date;

return date + " " + time;
}

public DomainFieldRow setDateInherited(boolean check)
Expand All @@ -1380,15 +1393,42 @@ public boolean isDateInherited()

public String getDateFormat()
{
return getFormatWithoutExample(elementCache().dateFormatSelect.getValue());
String formatValue;

if(elementCache().dateFormatSelect.isInteractive())
{
formatValue = getFormatWithoutExample(elementCache().dateFormatSelect.getValue());
}
else
{
formatValue = getFormatWithoutExample(elementCache().disabledDateFormat.getText());
}

return formatValue;
}

public boolean isDateFormatEnabled()
{
return elementCache().dateFormatSelect.isInteractive();
}

public DomainFieldRow setDateFormat(String dateFormat)
public DomainFieldRow setDateFormat(DATE_FORMAT dateFormat)
{
expand();
if (isDateInherited())
setDateInherited(false);
elementCache().dateFormatSelect.typeAheadSelect(dateFormat + " (");

String txt;
if (dateFormat.equals(DATE_FORMAT.DATE))
{
txt = dateFormat.toString();
}
else
{
txt = dateFormat + " (";
}
elementCache().dateFormatSelect.typeAheadSelect(txt);

return this;
}

Expand All @@ -1406,18 +1446,56 @@ public boolean isTimeInherited()

public String getTimeFormat()
{
return getFormatWithoutExample(elementCache().timeFormatSelect.getValue());
String formatValue;

if(elementCache().timeFormatSelect.isInteractive())
{
formatValue = getFormatWithoutExample(elementCache().timeFormatSelect.getValue());
}
else
{
formatValue = getFormatWithoutExample(elementCache().disabledTimeFormat.getText());
}

return formatValue;
}

public DomainFieldRow setTimeFormat(String timeFormat)
public boolean isTimeFormatEnabled()
{
return elementCache().timeFormatSelect.isInteractive();
}

public DomainFieldRow setTimeFormat(TIME_FORMAT timeFormat)
{
expand();
if (isTimeInherited())
setTimeInherited(false);
elementCache().timeFormatSelect.typeAheadSelect(timeFormat + " (");

String txt;

if (timeFormat.equals(TIME_FORMAT.TIME))
{
txt = timeFormat.toString();
}
else
{
txt = timeFormat + " (";
}

elementCache().timeFormatSelect.typeAheadSelect(txt);
return this;
}

public boolean hasDomainWarningIcon()
{
return elementCache().domainWarningIcon.isDisplayed();
}

public WebElement getDomainWarningIcon()
{
return elementCache().domainWarningIcon;
}

public static class DomainFieldRowFinder extends WebDriverComponentFinder<DomainFieldRow, DomainFieldRowFinder>
{
private final Locator.XPathLocator _baseLocator = Locator.tagWithClassContaining("div", "domain-field-row").withoutClass("domain-floating-hdr");
Expand Down Expand Up @@ -1523,15 +1601,25 @@ protected class ElementCache extends WebDriverComponent.ElementCache
public final FilteringReactSelect dateTimeFormatDateSelect = FilteringReactSelect.finder(getDriver())
.withNamedInput("domainpropertiesrow-format_datedateTime")
.refindWhenNeeded(this);
public final WebElement disabledDateTimeDateFormat = Locator.tagWithAttributeContaining("div", "id", "domainpropertiesrow-format_datedateTime")
.descendant("div[contains(@class,'select-input__single-value--is-disabled')]").findWhenNeeded(this);
public final FilteringReactSelect dateTimeFormatTimeSelect = FilteringReactSelect.finder(getDriver())
.withNamedInput("domainpropertiesrow-format_timedateTime")
.refindWhenNeeded(this);
public final WebElement disabledDateTimeTimeFormat = Locator.tagWithAttributeContaining("div", "id", "domainpropertiesrow-format_timedateTime")
.descendant("div[contains(@class,'select-input__single-value--is-disabled')]").findWhenNeeded(this);
public final FilteringReactSelect dateFormatSelect = FilteringReactSelect.finder(getDriver())
.withNamedInput("domainpropertiesrow-format_datedate")
.refindWhenNeeded(this);
public final WebElement disabledDateFormat = Locator.tagWithAttributeContaining("div", "id", "domainpropertiesrow-format_datedate")
.descendant("div[contains(@class,'select-input__single-value--is-disabled')]").findWhenNeeded(this);
public final FilteringReactSelect timeFormatSelect = FilteringReactSelect.finder(getDriver())
.withNamedInput("domainpropertiesrow-format_timetime")
.refindWhenNeeded(this);
public final WebElement disabledTimeFormat = Locator.tagWithAttributeContaining("div", "id", "domainpropertiesrow-format_timetime")
.descendant("div[contains(@class,'select-input__single-value--is-disabled')]").findWhenNeeded(this);
public final WebElement domainWarningIcon = Locator.tagWithClass("span", "domain-warning-icon")
.findWhenNeeded(this);

// lookup field options
public final Select lookupContainerSelect = SelectWrapper.Select(Locator.name("domainpropertiesrow-lookupContainer"))
Expand Down
36 changes: 35 additions & 1 deletion src/org/labkey/test/components/domain/DomainFormPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.labkey.test.components.html.Checkbox;
import org.labkey.test.components.react.ToggleButton;
import org.labkey.test.components.ui.grids.ResponsiveGrid;
import org.labkey.test.pages.core.admin.BaseSettingsPage.DATE_FORMAT;
import org.labkey.test.pages.core.admin.BaseSettingsPage.TIME_FORMAT;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.selenium.WebElementWrapper;
import org.openqa.selenium.NoSuchElementException;
Expand Down Expand Up @@ -125,7 +127,39 @@ private DomainFormPanel editField(DomainFieldRow fieldRow, FieldDefinition field
if (fieldDefinition.getLabel() != null)
fieldRow.setLabel(fieldDefinition.getLabel());
if (fieldDefinition.getFormat() != null)
fieldRow.setFormat(fieldDefinition.getFormat(), fieldDefinition.getRangeURI());
{
if (fieldDefinition.getType().equals(FieldDefinition.ColumnType.Date))
{
fieldRow.setDateFormat(DATE_FORMAT.get(fieldDefinition.getFormat()));
}
else if (fieldDefinition.getType().equals(FieldDefinition.ColumnType.Time))
{
fieldRow.setTimeFormat(TIME_FORMAT.get(fieldDefinition.getFormat()));
}
else if (fieldDefinition.getType().equals(FieldDefinition.ColumnType.DateAndTime))
{

// Identify the part of the format that is the date and the part that is the time. Take into account
// a data format may include spaces (time does not).
String format = fieldDefinition.getFormat().trim();
int index = format.lastIndexOf(" ");

if (format.substring(index + 1).contains(":"))
{
fieldRow.setDateTimeFormat(
DATE_FORMAT.get(format.substring(0, index)),
TIME_FORMAT.get(format.substring(index + 1)));
}
else
{
fieldRow.setDateTimeFormat(DATE_FORMAT.get(format));
}
}
else
{
fieldRow.setFormat(fieldDefinition.getFormat(), fieldDefinition.getRangeURI());
}
}
if (fieldDefinition.getScale() != null)
fieldRow.setCharCount(fieldDefinition.getScale());
if (fieldDefinition.getURL() != null)
Expand Down
Loading

0 comments on commit 3850d55

Please sign in to comment.