fix(grid): sort paginated table data server side

This commit is contained in:
jearhe authored and GitHub committed 2026-08-31 23:45:40 +08:00
1 parent f075caef21
commit 40a806a24a
5 files changed
+251 -6

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { ELASTICSEARCH_PAGE_JUMP_WARNING_REQUESTS, elasticsearchCursorPageJumpRequestCount } from "@/lib/dataGrid/dataGridPagination";
import { ELASTICSEARCH_PAGE_JUMP_WARNING_REQUESTS, elasticsearchCursorPageJumpRequestCount, hasCompleteLocalDataGridResult } from "@/lib/dataGrid/dataGridPagination";
describe("Elasticsearch cursor page jumps", () => {
it("counts only missing forward cursors", () => {
@@ -17,3 +17,40 @@ describe("Elasticsearch cursor page jumps", () => {
expect(elasticsearchCursorPageJumpRequestCount(1, 101)).toBe(ELASTICSEARCH_PAGE_JUMP_WARNING_REQUESTS);
});
});
describe("complete local DataGrid results", () => {
it("recognizes complete results without treating a partial page as complete", () => {
expect(
hasCompleteLocalDataGridResult({
isResultsContext: true,
rowCount: 3,
pageLimit: 10,
pageOffset: 0,
truncated: false,
hasMore: false,
}),
).toBe(true);
expect(
hasCompleteLocalDataGridResult({
isResultsContext: true,
rowCount: 10,
pageLimit: 10,
pageOffset: 0,
totalRowCount: 25,
truncated: false,
hasMore: false,
}),
).toBe(false);
expect(
hasCompleteLocalDataGridResult({
isResultsContext: true,
rowCount: 20,
pageLimit: 10,
pageOffset: 10,
totalRowCount: 20,
truncated: false,
hasMore: false,
}),
).toBe(false);
});
});