Grids: retarget counting methods to dataSourceController - #35131
Grids: retarget counting methods to dataSourceController#35131anna-shakhova wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Pull request overview
Retargets hasKnownLastPage from DataController to DataSourceController and updates grid pager/virtual scrolling code and tests to use the new location.
Changes:
- Added
DataSourceController.hasKnownLastPage()and unit tests for delegation/default behavior. - Updated pager + virtual scrolling logic to call
dataSourceController.hasKnownLastPage()instead ofdataController.hasKnownLastPage(). - Updated QUnit tests and added a Jest integration test for
PagerViewto validate pager options/visibility.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/pagerView.tests.js | Updates pager QUnit test to assert against dataSourceController.hasKnownLastPage(). |
| packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/dataController.tests.js | Repoints multiple assertions to dataSourceController.hasKnownLastPage(). |
| packages/devextreme/testing/helpers/gridBaseMocks.js | Moves hasKnownLastPage mock to align with the controller responsibility shift. |
| packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/m_virtual_scrolling.ts | Uses dataSourceController.hasKnownLastPage() for bottom-loading visibility checks. |
| packages/devextreme/js/__internal/grids/grid_core/virtual_scrolling/extenders/virtual_scrolling_data_controller.ts | Delegates hasKnownLastPage checks to dataSourceController. |
| packages/devextreme/js/__internal/grids/grid_core/pager/m_pager.ts | Pager now reads hasKnownLastPage from dataSourceController; adds controller field. |
| packages/devextreme/js/__internal/grids/grid_core/pager/tests/pager_view.integration.test.ts | New integration tests covering pager options and auto-visibility. |
| packages/devextreme/js/__internal/grids/grid_core/data_source/data_source_controller.ts | Adds hasKnownLastPage() API with safe default when no adapter. |
| packages/devextreme/js/__internal/grids/grid_core/data_source/tests/data_source_controller.test.ts | Tests default true and adapter delegation for hasKnownLastPage(). |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts | Removes DataController.hasKnownLastPage() implementation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hasKnownLastPage methodThere was a problem hiding this comment.
🟡 Changes recommended
The updated test mock MockDataSourceAdapter.totalItemsCount() can return undefined, which can propagate into production-like code paths and produce NaN in numeric computations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 1
- Review effort level: Lite
9ef5549 to
99bde8e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The updated test adapter in gridBaseMocks.js can return undefined/coerce valid values for counts, which can break DataSourceController-based logic and cause incorrect behavior in tests/runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 24/24 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
The updated test mocks can return undefined for pageCount/totalItemsCount, which diverges from production defaults and can break arithmetic/comparisons in code paths that now rely on dataSourceController.
Review details
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
packages/devextreme/js/__internal/grids/grid_core/data_source/tests/data_source_controller.integration.test.ts:80
- The test name says the controller "sits at the bottom" of the controller order, but the assertion checks that it's the first entry. Consider renaming the test to match the expectation (e.g., "is created first"), so future readers don’t misinterpret the intended ordering.
it('sits at the bottom of the controller order', async () => {
const { instance } = await createDataGrid({ dataSource: DATA });
expect(getControllerNames(instance)[0]).toBe('dataSource');
});
packages/devextreme/testing/helpers/gridBaseMocks.js:69
- MockDataSourceAdapter.pageCount() can return undefined when options.pageCount is not provided, but the real DataSourceController.pageCount() defaults to 1. Returning undefined can break code paths that do arithmetic like pageCount() - 1.
packages/devextreme/testing/helpers/gridBaseMocks.js:63
- MockDataSourceAdapter.totalItemsCount() can return undefined when options.totalItemsCount is not provided, but callers (and the real DataSourceController.totalItemsCount()) expect a number (defaulting to 0). This can lead to NaN/incorrect comparisons in tests using these mocks.
totalItemsCount: function() {
return options.totalItemsCount;
},
- Files reviewed: 25/25 changed files
- Comments generated: 0 new
- Review effort level: Lite
No description provided.