1 parent
c163adc8e5
commit
680358aff8
2 files changed
+14
-1
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
|
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
|
||||||
|
|
||||||
const STORAGE_KEY = "dbx-data-grid-condition-history";
|
const STORAGE_KEY = "dbx-data-grid-condition-history";
|
||||||
const MAX_HISTORY_PER_SCOPE = 12;
|
const MAX_HISTORY_PER_SCOPE = 20;
|
||||||
|
|
||||||
export type DataGridConditionHistoryKind = "where" | "orderBy";
|
export type DataGridConditionHistoryKind = "where" | "orderBy";
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,19 @@ test("keeps WHERE and ORDER BY histories separate", () => {
|
|||||||
assert.deepEqual(loadDataGridConditionHistory("orderBy", scope), ["created_at DESC"]);
|
assert.deepEqual(loadDataGridConditionHistory("orderBy", scope), ["created_at DESC"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.each(["where", "orderBy"] as const)("keeps the newest 20 %s history entries", (kind) => {
|
||||||
|
const scope = { connectionId: "c1", database: "app", schema: "public", tableName: "users" };
|
||||||
|
|
||||||
|
for (let index = 1; index <= 21; index += 1) {
|
||||||
|
rememberDataGridConditionHistory(kind, scope, `condition ${index}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
loadDataGridConditionHistory(kind, scope),
|
||||||
|
Array.from({ length: 20 }, (_, index) => `condition ${21 - index}`),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("filters history by partial input and isolates different tables", () => {
|
test("filters history by partial input and isolates different tables", () => {
|
||||||
const users = { connectionId: "c1", database: "app", schema: "public", tableName: "users" };
|
const users = { connectionId: "c1", database: "app", schema: "public", tableName: "users" };
|
||||||
const orders = { connectionId: "c1", database: "app", schema: "public", tableName: "orders" };
|
const orders = { connectionId: "c1", database: "app", schema: "public", tableName: "orders" };
|
||||||
|
|||||||
Reference in new issue
Block a user