refactor: centralized the iam seeder

This commit is contained in:
Nathnael
2026-07-27 08:28:57 +00:00
parent 1fe10ee3c2
commit 03b8ca0ce7
19 changed files with 1339 additions and 592 deletions

View File

@@ -0,0 +1,27 @@
import { missingSettings } from "./missing-settings.util";
const defaults = [
{ key: "primaryColor", displayName: "Primary Color", value: null },
{ key: "logoFileUrl", displayName: "Logo", value: null },
];
describe("missingSettings", () => {
it("returns every default when the owner has none", () => {
expect(missingSettings(defaults, new Set(), "org-1")).toHaveLength(2);
});
it("skips keys the owner has, but not the same key on another owner", () => {
const existing = new Set(["org-1:primaryColor"]);
expect(
missingSettings(defaults, existing, "org-1").map((s) => s.key),
).toEqual(["logoFileUrl"]);
expect(missingSettings(defaults, existing, "org-2")).toHaveLength(2);
});
it("drops nulls so the column default applies", () => {
expect(
missingSettings(defaults, new Set(), "org-1")[0].value,
).toBeUndefined();
});
});