Datatable: Lazy Sorting Regression
See original GitHub issueDescribe the defect After the new sorting was implemented in https://github.com/primefaces/primefaces/issues/5438 one of the Integration Test Cases is now failing.
Error DataTable002Test.testLazyFilter:151 expected: <Language 18> but was: <Language 9>
Reproducer Integration Test: https://github.com/primefaces-extensions/primefaces-integration-tests/blob/dc72818c1e099191b6e47bf2b9e46ab85801de54/src/test/java/org/primefaces/extensions/integrationtests/datatable/DataTable002Test.java#L126-L154
Environment:
- PF Version: 9.0
Example XHTML
<h:form id="frmTest">
<p:dataTable id="datatable" value="#{dataTable002.lazyDataModel}" var="lang" paginator="true" rows="10" filteredValue="#{dataTable002.filteredProgLanguages}" lazy="true">
<p:column headerText="ID" sortBy="#{lang.id}">
<h:outputText value="#{lang.id}" />
</p:column>
<p:column headerText="Name" sortBy="#{lang.name}" filterBy="#{lang.name}" filterMatchMode="contains">
<h:outputText value="#{lang.name}" />
</p:column>
<p:column headerText="First appeared" sortBy="#{lang.firstAppeared}" filterBy="#{lang.firstAppeared}" filterMatchMode="gte">
<h:outputText value="#{lang.firstAppeared}" />
</p:column>
</p:dataTable>
</h:form>
Integration Test
@Test
@Order(3)
@DisplayName("DataTable: Lazy: filter")
public void testLazyFilter(Page page) {
// Arrange
DataTable dataTable = page.dataTable;
Assertions.assertNotNull(dataTable);
List<ProgrammingLanguage> langsFiltered = langs.getLangs().stream()
.filter(l -> l.getFirstAppeared() >= 1998)
.sorted(Comparator.comparingInt(ProgrammingLanguage::getFirstAppeared))
.collect(Collectors.toList());
// Act
dataTable.selectPage(1);
dataTable.sort("First appeared");
dataTable.filter("First appeared", "1998");
// Assert
List<Row> rows = dataTable.getRows();
Assertions.assertNotNull(rows);
Assertions.assertEquals(10, rows.size()); //one page
Assertions.assertEquals(langsFiltered.get(0).getName(), rows.get(0).getCell(1).getText());
Assertions.assertEquals(langsFiltered.get(1).getName(), rows.get(1).getCell(1).getText()); //fails
assertConfiguration(dataTable.getWidgetConfiguration());
}
We sort by First Appeared year and you can see its sorted correctly:
Then we filter by year 1998
and the filtering works but the list is now unsorted with 1998 and 1999 mixed together even though the column is sorted. So our test fails because record #2 should not be 1999 it should be another 1998 DataTable002Test.testLazyFilter:151 expected: <Language 18> but was: <Language 9>
It appears to be sorted by the Id
column now again.
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (23 by maintainers)
Top GitHub Comments
i will get a beer now and explain when state/fields etc. are used 😃
@Rapster thank you I can confirm all the Integration Tests are now passing including all of the tests that were added to prove you have fixed the other sorting defects! https://github.com/primefaces-extensions/primefaces-integration-tests/actions/runs/352863652