fix(grid): budget large-value previews by segment and show executed SQL
This commit is contained in:
12 files changed
+194
-10
No files matched your search
+21
-1
@@ -1,6 +1,6 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import { test } from "vitest";
|
||||
import { canFetchNextDataGridSegment, canGoNextDataGridPage, dataGridLoadAllSegment, hasCompleteLocalDataGridResult, resolveDataGridPaginationTotal } from "../../apps/desktop/src/lib/dataGrid/dataGridPagination.ts";
|
||||
import { canFetchNextDataGridSegment, canGoNextDataGridPage, dataGridLoadAllSegment, dataGridUserFacingPage, hasCompleteLocalDataGridResult, resolveDataGridPaginationTotal } from "../../apps/desktop/src/lib/dataGrid/dataGridPagination.ts";
|
||||
|
||||
test("estimated display totals do not become pagination bounds", () => {
|
||||
assert.equal(
|
||||
@@ -244,3 +244,23 @@ test("auto-redirect: total is undefined — guard prevents redirect attempt", ()
|
||||
const total = undefined;
|
||||
assert.equal(!total || (total as any) <= 0, true, "guard should prevent redirect when total is unknown");
|
||||
});
|
||||
|
||||
test("the SQL shown under the grid describes the segment that actually ran", () => {
|
||||
// "Load all" keeps resultPageLimit/Offset on the logical first page, so the
|
||||
// footer has to read the executed segment instead of claiming LIMIT 100.
|
||||
assert.deepEqual(
|
||||
dataGridUserFacingPage({
|
||||
executedPageLimit: 99_900,
|
||||
executedPageOffset: 100,
|
||||
pageLimit: 100,
|
||||
pageOffset: 0,
|
||||
fallbackLimit: 100,
|
||||
fallbackOffset: 0,
|
||||
}),
|
||||
{ limit: 99_900, offset: 100 },
|
||||
);
|
||||
assert.deepEqual(dataGridUserFacingPage({ executedPageLimit: 100, executedPageOffset: 200, pageLimit: 100, pageOffset: 200, fallbackLimit: 100, fallbackOffset: 0 }), { limit: 100, offset: 200 });
|
||||
// Snapshots written before the executed page existed fall back to the page props.
|
||||
assert.deepEqual(dataGridUserFacingPage({ pageLimit: 50, pageOffset: 150, fallbackLimit: 100, fallbackOffset: 0 }), { limit: 50, offset: 150 });
|
||||
assert.deepEqual(dataGridUserFacingPage({ fallbackLimit: 100, fallbackOffset: 300 }), { limit: 100, offset: 300 });
|
||||
});
|
||||
+4
@@ -4818,6 +4818,8 @@ test("data tab execution preserves pagination offset metadata", async () => {
|
||||
assert.equal(executeBody.schema, undefined);
|
||||
assert.equal(tab.resultPageLimit, 100);
|
||||
assert.equal(tab.resultPageOffset, 100);
|
||||
assert.equal(tab.resultExecutedPageLimit, 100);
|
||||
assert.equal(tab.resultExecutedPageOffset, 100);
|
||||
assert.deepEqual(tab.result?.rows, [[101]]);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
@@ -4881,6 +4883,8 @@ test("append pagination preserves existing rows and respects the memory cap", as
|
||||
assert.equal(tab.result?.has_more, false);
|
||||
assert.equal(tab.resultPageOffset, 0, "later refreshes must restart from the logical result origin");
|
||||
assert.equal(tab.resultPageLimit, 1000, "a short appended segment must preserve the base display page size");
|
||||
assert.equal(tab.resultExecutedPageOffset, 1, "the SQL shown for the grid describes the appended segment");
|
||||
assert.equal(tab.resultExecutedPageLimit, 2);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
restoreStorage();
|
||||
|
||||
Reference in new issue
Block a user