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
10 changes: 10 additions & 0 deletions src/org/labkey/test/components/domain/DomainFieldRow.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -518,11 +518,21 @@ public boolean hasFieldError()
{
return getComponentElement().getAttribute("class").contains("domain-row-border-error");
}
public DomainFieldRow waitForError()
{
getWrapper().waitFor(()-> this.hasFieldError(), WAIT_FOR_JAVASCRIPT);
return this;
}

public boolean hasFieldWarning()
{
return getComponentElement().getAttribute("class").contains("domain-row-border-warning");
}
public DomainFieldRow waitForWarning()
{
getWrapper().waitFor(()-> this.hasFieldWarning(), WAIT_FOR_JAVASCRIPT);
return this;
}

// conditional formatting and validation options

Expand Down
32 changes: 22 additions & 10 deletions src/org/labkey/test/tests/DomainDesignerTest.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,9 @@
import java.util.Map;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand DownExpand Up@@ -305,6 +307,12 @@ public void testBlankNameFieldOnAddedField() throws Exception
assertTrue("expect error to contain [Please provide a name for each field.] but was[" + hasNoNameError + "]",
hasNoNameError.contains("Please provide a name for each field."));

String warningFieldMessage = noNameRow.setName("&has weird characters that make scripts hard to write")
.waitForWarning()
.detailsMessage();
String expectedWarning = "New field. Warning: SQL queries, R scripts, and other code are easiest to write when field names only contain combination of letters, numbers, and underscores, and start with a letter or underscore";
assertThat("expected error", warningFieldMessage, containsString(expectedWarning));

domainDesignerPage.clickCancelAndDiscardChanges();
Comment thread
labkey-chrisj marked this conversation as resolved.
}

Expand DownExpand Up@@ -470,7 +478,7 @@ public void testConfirmNameFieldFromSamplesetNotShown() throws Exception
}

@Test
public void testAddFieldsWithReservedNames() throws Exception
public void testFieldNameErrors() throws Exception
{
String sampleSet = "fieldsWithReservedNamesSampleSet";

Expand All@@ -491,15 +499,19 @@ public void testAddFieldsWithReservedNames() throws Exception
DomainFieldRow clientFieldWarning = domainFormPanel.addField("select * from table");
Comment thread
labkey-chrisj marked this conversation as resolved.

domainDesignerPage.clickFinishExpectingError();
// TODO: Look for warning on row instead of banner. We're not doing warning banners anymore
// String clientWarning = domainDesignerPage.waitForWarning();
// String multipleIssuesError = domainDesignerPage.waitForError();
// String expectedErrMsg = "Multiple fields contain issues that need to be fixed. Review the red highlighted fields below for more information.";
// String expectedWarningMsg = " SQL queries, R scripts, and other code are easiest to write when field names only contain combination of letters, numbers, and underscores, and start with a letter or underscore.";
// assertTrue("expect error message to contain [" + expectedErrMsg + "] but was [" + multipleIssuesError + "]",
// multipleIssuesError.contains(expectedErrMsg));
// assertTrue("expect warning message to contain [" + expectedWarningMsg + "] but was [" + clientWarning + "]",
// clientWarning.contains(expectedWarningMsg));
String expectedWarnMsg = "New field. Warning: SQL queries, R scripts, and other code are easiest to write when field names only contain combination of letters, numbers, and underscores, and start with a letter or underscore.";
String blargErrMsg = "New field. Error: The field name 'blarg' is already taken. Please provide a unique name for each field.";
String reservedErrMsg = "New field. Error: 'modified' is a reserved field name in 'fieldsWithReservedNamesSampleSet'.";
String modRowDetailsMsg = modifiedRow.waitForError()
.detailsMessage();
String blarg1DetailsMsg = blarg1.waitForError().detailsMessage();
String blarg2DetailsMsg = blarg2.waitForError().detailsMessage();
String clientFieldWarningMsg = clientFieldWarning.waitForWarning().detailsMessage();

assertThat("expected warning", clientFieldWarningMsg, containsString(expectedWarnMsg));
assertThat("expected error", blarg1DetailsMsg, containsString(blargErrMsg));
assertThat("expected error", blarg2DetailsMsg, containsString(blargErrMsg));
assertThat("expected error", modRowDetailsMsg, containsString(reservedErrMsg));

assertTrue("expect field error when using reserved field names", modifiedRow.hasFieldError());
assertTrue("expect error for duplicate field names", blarg1.hasFieldError());
Comment thread
labkey-chrisj marked this conversation as resolved.
Expand Down