feat: add managed database capture and operator restore
PostgreSQL and MySQL backups run through paired outposts, with operator sign-in, off-site copies, and legacy import. Retention stays on each orbit, so the unused retention console is removed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
web/scripts/search.test.mjs
Normal file
38
web/scripts/search.test.mjs
Normal file
@@ -0,0 +1,38 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { formatWhen } from "../src/lib/format.ts";
|
||||
import { createVaultSearch } from "../src/lib/vaultSearch.ts";
|
||||
|
||||
const navigation = [{ id: "orbits", label: "Orbits", icon: "" }];
|
||||
const orbit = (id, name = "Orbits", provider = "filesystem") => ({ id, name, provider });
|
||||
const snapshot = (id, taken_at, orbit_name = "Orbits") => ({ id, taken_at, orbit_name });
|
||||
|
||||
test("ranks exact, prefix, and substring matches case-insensitively", () => {
|
||||
const orbits = [orbit("a", "Nightly Vault"), orbit("b", "Vault mirror"), orbit("c", "vault")];
|
||||
const search = createVaultSearch(navigation, orbits);
|
||||
const [group] = search(" VAULT ");
|
||||
assert.deepEqual(group.results.map(({ id }) => id), ["c", "b", "a"]);
|
||||
assert.equal(search("FILESYSTEM")[0].results.length, 3);
|
||||
});
|
||||
|
||||
test("keeps duplicate names distinguishable and sorts equivalent snapshots newest first", () => {
|
||||
const orbits = [orbit("alpha"), orbit("beta", "Orbits", "postgres")];
|
||||
const snapshots = [snapshot("old", "2025-01-01T00:00:00Z"), snapshot("new", "2025-02-01T00:00:00Z")];
|
||||
const search = createVaultSearch(navigation, orbits, snapshots);
|
||||
const [, orbitGroup, snapshotGroup] = search("orbits");
|
||||
assert.equal(new Set(orbitGroup.results.map(({ detail }) => detail)).size, 2);
|
||||
assert.deepEqual(snapshotGroup.results.map(({ id }) => id), ["new", "old"]);
|
||||
assert.equal(search(formatWhen(snapshots[0].taken_at))[0].results[0].id, "old");
|
||||
assert.equal(search("beta")[0].results[0].id, "beta");
|
||||
});
|
||||
|
||||
test("reserves a place for every matching category within the eight-result limit", () => {
|
||||
const orbits = Array.from({ length: 12 }, (_, index) => orbit(`orbit-${index}`));
|
||||
const snapshots = [snapshot("snap", "2025-02-01T00:00:00Z")];
|
||||
const search = createVaultSearch(navigation, orbits, snapshots);
|
||||
const groups = search("orbits");
|
||||
assert.deepEqual(groups.map(({ label }) => label), ["Navigation", "Orbits", "Snapshots"]);
|
||||
assert.equal(groups.flatMap(({ results }) => results).length, 8);
|
||||
assert.deepEqual(search(" ").map(({ label }) => label), ["Navigation"]);
|
||||
assert.deepEqual(search("no match"), []);
|
||||
});
|
||||
Reference in New Issue
Block a user