Skip to content

Commit abc603e

Browse files
Issue 53796: DataRegion.getChecked() incorrectly HTML encodes (#2655)
1 parent b57f033 commit abc603e

File tree

2 files changed

+50
-28
lines changed

2 files changed

+50
-28
lines changed

src/org/labkey/test/tests/DataRegionTest.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import java.util.Map;
4040

4141
import static org.junit.Assert.assertEquals;
42+
import static org.junit.Assert.assertFalse;
43+
import static org.junit.Assert.assertTrue;
4244
import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS;
4345

4446
@Category({Daily.class, Data.class})
@@ -199,13 +201,13 @@ private void dataRegionTest(URL url, String dataRegionName) throws MalformedURLE
199201
assertEquals(TOTAL_ROWS, table.getDataRowCount());
200202
assertEquals("aqua", table.getDataAsText(0, "Name"));
201203
assertEquals("#FFFF00", table.getDataAsText(15, "Hex"));
202-
assertEquals(false, table.getPagingWidget().hasPagingButton(true));
203-
assertEquals(false, table.getPagingWidget().hasPagingButton(false));
204+
assertFalse(table.getPagingWidget().hasPagingButton(true));
205+
assertFalse(table.getPagingWidget().hasPagingButton(false));
204206

205207
log("Test 3 per page");
206208
table.setMaxRows(3);
207-
assertEquals(true, table.getPagingWidget().hasPagingButton(true));
208-
assertEquals(true, table.getPagingWidget().hasPagingButton(false));
209+
assertTrue(table.getPagingWidget().hasPagingButton(true));
210+
assertTrue(table.getPagingWidget().hasPagingButton(false));
209211
table.getPagingWidget().viewPagingOptions();
210212
assertElementPresent(Locator.linkWithText("3 per page").notHidden().append(Locator.tagWithClass("i", "fa-check-square-o")));
211213
assertElementPresent(Locator.linkWithText("20 per page").notHidden());
@@ -221,40 +223,40 @@ private void dataRegionTest(URL url, String dataRegionName) throws MalformedURLE
221223
table.assertPaginationText(1, 5, 16);
222224
assertEquals(5, table.getDataRowCount());
223225
assertEquals("aqua", table.getDataAsText(0, "Name"));
224-
assertEquals(false, table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
225-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
226-
assertEquals(false, table.getPagingWidget().pagingButtonEnabled(true));
227-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(false));
226+
assertFalse(table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
227+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
228+
assertFalse(table.getPagingWidget().pagingButtonEnabled(true));
229+
assertTrue(table.getPagingWidget().pagingButtonEnabled(false));
228230

229231
log("Next Page");
230232
table.pageNext();
231233
table.assertPaginationText(6, 10, 16);
232234
assertEquals(5, table.getDataRowCount());
233235
assertEquals("grey", table.getDataAsText(0, "Name"));
234-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
235-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
236-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(true));
237-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(false));
236+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
237+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
238+
assertTrue(table.getPagingWidget().pagingButtonEnabled(true));
239+
assertTrue(table.getPagingWidget().pagingButtonEnabled(false));
238240

239241
log("Last Page");
240242
table.pageLast();
241243
table.assertPaginationText(16, 16, 16);
242244
assertEquals(1, table.getDataRowCount());
243245
assertEquals("yellow", table.getDataAsText(0, "Name"));
244-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
245-
assertEquals(false, table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
246-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(true));
247-
assertEquals(false, table.getPagingWidget().pagingButtonEnabled(false));
246+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
247+
assertFalse(table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
248+
assertTrue(table.getPagingWidget().pagingButtonEnabled(true));
249+
assertFalse(table.getPagingWidget().pagingButtonEnabled(false));
248250

249251
log("Previous Page");
250252
table.pagePrev();
251253
table.assertPaginationText(11, 15, 16);
252254
assertEquals(5, table.getDataRowCount());
253255
assertEquals("purple", table.getDataAsText(0, "Name"));
254-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
255-
assertEquals(true, table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
256-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(true));
257-
assertEquals(true, table.getPagingWidget().pagingButtonEnabled(false));
256+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show first", "Show first"));
257+
assertTrue(table.getPagingWidget().menuOptionEnabled("Show last", "Show last"));
258+
assertTrue(table.getPagingWidget().pagingButtonEnabled(true));
259+
assertTrue(table.getPagingWidget().pagingButtonEnabled(false));
258260

259261
log("Setting a filter should go back to first page");
260262
table.setFilter(NAME_COLUMN.getName(), "Does Not Equal", "aqua");
@@ -266,7 +268,7 @@ private void dataRegionTest(URL url, String dataRegionName) throws MalformedURLE
266268
Locator.XPathLocator selectionPart = Locator.tagWithAttribute("div", "data-msgpart", "selection");
267269
waitForElement(selectionPart);
268270
WebElement msgDiv = selectionPart.findElement(getDriver());
269-
assertEquals(true, msgDiv.getText().contains("Selected 5 of 15 rows."));
271+
assertTrue(msgDiv.getText().contains("Selected 5 of 15 rows."));
270272

271273
assertElementPresent(selectionPart.append(Locator.tagWithClass("span", "select-all")));
272274
assertElementPresent(selectionPart.append(Locator.tagWithClass("span", "select-none")));
@@ -284,7 +286,7 @@ private void dataRegionTest(URL url, String dataRegionName) throws MalformedURLE
284286
private void enableComplianceIfInstalled()
285287
{
286288
// Make sure it works with Compliance on (which enables Elec Sign control)
287-
// Have to do what enableModule does in order to check if it's installed
289+
// Have to do what enableModule does to check if it's installed
288290
goToFolderManagement();
289291
clickAndWait(Locator.linkWithText("Folder Type"));
290292

src/org/labkey/test/tests/list/ListTest.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.labkey.test.params.FieldDefinition;
5454
import org.labkey.test.params.FieldDefinition.StringLookup;
5555
import org.labkey.test.params.FieldKey;
56+
import org.labkey.test.params.list.IntListDefinition;
5657
import org.labkey.test.params.list.VarListDefinition;
5758
import org.labkey.test.tests.AuditLogTest;
5859
import org.labkey.test.util.AbstractDataRegionExportOrSignHelper.ColumnHeaderType;
@@ -97,6 +98,7 @@ public class ListTest extends BaseWebDriverTest
9798
protected final static String PROJECT_VERIFY = "ListVerifyProject" ;//+ TRICKY_CHARACTERS_FOR_PROJECT_NAMES;
9899
private final static String PROJECT_OTHER = "OtherListVerifyProject";
99100
protected final static String LIST_NAME_COLORS = "A_Colors_" + DOMAIN_TRICKY_CHARACTERS;
101+
protected final static String LIST_NAME_HTML_KEY = "A_HtmlKey_" + DOMAIN_TRICKY_CHARACTERS;
100102
protected final static ColumnType LIST_KEY_TYPE = ColumnType.String;
101103
protected final static String LIST_KEY_NAME = "Key";
102104

@@ -260,15 +262,33 @@ protected void setUpListFinish()
260262
.submit();
261263
}
262264

265+
/** Issue 53796: 25.3 -> 25.7: DataRegion.getChecked() incorrectly HTML encodes the results */
266+
@Test
267+
public void testKeyWithHtmlCharacters()
268+
{
269+
_listHelper.createList(getProjectName(), LIST_NAME_HTML_KEY, new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE));
270+
ImportDataPage importDataPage = _listHelper.clickImportData();
271+
String value = "<>ThisIsTheKeyValueWithHtmlCharacters</>";
272+
importDataPage.setText(LIST_KEY_NAME2_BULK + "\n" + value);
273+
importDataPage.submit();
274+
assertTextPresent(value);
275+
final DataRegionTable dt = DataRegion(getDriver()).withName("query").find();
276+
dt.checkAllOnPage();
277+
@SuppressWarnings("unchecked") List<String> checked = (List<String>)executeScript("return LABKEY.DataRegions.query.getChecked()");
278+
assertEquals(Arrays.asList(value), checked);
279+
dt.deleteSelectedRows();
280+
assertTextNotPresent(value);
281+
}
282+
263283
@LogMethod
264-
protected void setUpList(String projectName)
284+
protected void setUpList()
265285
{
266286
// TODO: Break this up into explicit test cases and remove redundant test coverage.
267287
// But at least now it's only called from the one test case that relies on this list, testCustomViews().
268288
// Previously it was called from the @BeforeClass method, even though none of the other test cases use this list.
269289

270290
log("Add list -- " + LIST_NAME_COLORS);
271-
_listHelper.createList(projectName, LIST_NAME_COLORS, new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE), _listColFake,
291+
_listHelper.createList(getProjectName(), LIST_NAME_COLORS, new FieldDefinition(LIST_KEY_NAME2, LIST_KEY_TYPE), _listColFake,
272292
_listColMonth, _listColTone);
273293

274294
log("Add description and test edit");
@@ -307,13 +327,13 @@ protected void setUpList(String projectName)
307327
log("Test check/uncheck of checkboxes");
308328
// Second row (Green)
309329
assertEquals(1, table.getRowIndex(TEST_DATA[TD_COLOR][1]));
310-
clickAndWait(table.updateLink(1));
330+
table.clickEditRow(1);
311331
setFormElement(Locator.name("quf_" + _listColMonth.getName()), VALID_MONTHS[1]); // Has a funny format -- need to post converted date
312332
checkCheckbox(Locator.checkboxByName("quf_JewelTone"));
313333
clickButton("Submit");
314334
// Third row (Red)
315335
assertEquals(2, table.getRowIndex(TEST_DATA[TD_COLOR][2]));
316-
clickAndWait(table.updateLink(2));
336+
table.clickEditRow(2);
317337
setFormElement(Locator.name("quf_" + _listColMonth.getName()), VALID_MONTHS[2]); // Has a funny format -- need to post converted date
318338
uncheckCheckbox(Locator.checkboxByName("quf_JewelTone"));
319339
clickButton("Submit");
@@ -578,7 +598,7 @@ public void testCreateListWithBOMFile()
578598
public void testCustomViews()
579599
{
580600
goToProjectHome();
581-
setUpList(getProjectName());
601+
setUpList();
582602

583603
goToProjectHome();
584604
waitAndClickAndWait(Locator.linkWithText(LIST_NAME_COLORS));
@@ -1062,7 +1082,7 @@ public void listSelfJoinTest()
10621082
clickButton("Edit");
10631083
assertTextPresent("dummy one");
10641084
clickButton("Cancel");
1065-
clickAndWait(regionTable.updateLink(0));
1085+
regionTable.clickEditRow(0);
10661086
assertTextPresent("dummy one");
10671087
clickButton("Cancel");
10681088
}

0 commit comments

Comments
 (0)