feat(grid): preserve data-grid viewport and selection across tab switches
This commit is contained in:
1 parent
2b26bd6a1a
commit
41b5e51dcc
21 files changed
+1231
-8
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { decodeTabResultSnapshot, encodeTabResultSnapshot } from "@/lib/tabs/tabResultCache";
|
||||
import type { QueryResult } from "@/types/database";
|
||||
|
||||
function sampleResult(): QueryResult {
|
||||
return {
|
||||
columns: ["id", "name"],
|
||||
rows: [[1, "a"]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
};
|
||||
}
|
||||
|
||||
describe("tab result cache view generation", () => {
|
||||
it("round-trips the tab-level view generation for a data tab with no runs", () => {
|
||||
const restored = decodeTabResultSnapshot(
|
||||
encodeTabResultSnapshot({
|
||||
result: sampleResult(),
|
||||
resultViewGeneration: "gen-data-tab",
|
||||
cachedAt: 1,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(restored?.resultViewGeneration).toBe("gen-data-tab");
|
||||
});
|
||||
|
||||
it("round-trips the per-run view generation", () => {
|
||||
const restored = decodeTabResultSnapshot(
|
||||
encodeTabResultSnapshot({
|
||||
resultRuns: [{ id: "run-1", title: "Run 1", sequence: 1, sql: "select 1", createdAt: 1, result: sampleResult(), resultViewGeneration: "gen-run" }],
|
||||
activeResultRunId: "run-1",
|
||||
cachedAt: 1,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(restored?.resultRuns?.[0]?.resultViewGeneration).toBe("gen-run");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user