Let a super admin read the database from the app
A new super admin settings page, /admin/settings/database, lists every table with its record count and size, and one page of the open table's records newest key first. Values are cut inside SQL (400 characters, with a flag saying so) and a record opens whole in a modal, so a table of long texts reads without shipping it all. A search matches every column's text, word by word or as a phrase, which is the one thing that also works on a virtual table. Nothing in it writes: the catalog, the records and the single record are all reads, GET only.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import clampPage from "./clamp-page";
|
||||
|
||||
describe("clampPage", () => {
|
||||
test("keeps a page that is inside the table", () => {
|
||||
expect(clampPage({ page: 2, total: 120, page_size: 50 })).toBe(2);
|
||||
});
|
||||
|
||||
test("a page past the end lands on the last one", () => {
|
||||
expect(clampPage({ page: 99, total: 120, page_size: 50 })).toBe(3);
|
||||
});
|
||||
|
||||
test("an empty table still has a first page", () => {
|
||||
expect(clampPage({ page: 4, total: 0, page_size: 50 })).toBe(1);
|
||||
});
|
||||
|
||||
test("a page below one is the first", () => {
|
||||
expect(clampPage({ page: 0, total: 120, page_size: 50 })).toBe(1);
|
||||
expect(clampPage({ page: -3, total: 120, page_size: 50 })).toBe(1);
|
||||
});
|
||||
|
||||
test("a table that fits exactly ends on the page asked for", () => {
|
||||
expect(clampPage({ page: 2, total: 100, page_size: 50 })).toBe(2);
|
||||
expect(clampPage({ page: 3, total: 100, page_size: 50 })).toBe(2);
|
||||
});
|
||||
|
||||
test("a page size of nothing doesn't divide by zero", () => {
|
||||
expect(clampPage({ page: 1, total: 10, page_size: 0 })).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user