test: define acl and import backend contracts
This commit is contained in:
1 parent
63ab21616c
commit
667ec9af4c
2 files changed
+45
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("ACL management contract", () => {
|
||||
it("uses normalized ACL persistence and the permissions.manage guard", () => {
|
||||
const source = readFileSync("src/actions/permissions.ts", "utf8");
|
||||
expect(source).toContain("PERMS.PERMISSIONS_MANAGE");
|
||||
expect(source).toContain("adminAction");
|
||||
expect(source).toContain("aclModelPermission");
|
||||
expect(source).not.toContain("websiteHousekeepingPermissions");
|
||||
expect(source).not.toContain("websiteTeams");
|
||||
});
|
||||
|
||||
it("ships an idempotent ACL completion migration", () => {
|
||||
const sql = readFileSync("prisma/migrations/0014_complete_acl_and_import_permissions.sql", "utf8");
|
||||
expect(sql).toContain("admin.assets.import");
|
||||
expect(sql).toContain("rank_");
|
||||
expect(sql).toContain("'Role'");
|
||||
expect(sql).toContain("'User'");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const ROUTES = [
|
||||
"badges", "badges/edit", "clone", "clone/batch", "clone/icon",
|
||||
"clothing", "clothing/batch", "clothing/sets", "clothing/sets/batch",
|
||||
"effects", "effects/batch", "furni", "furni/batch", "furni/batch-regen",
|
||||
"furni/nitro-editor", "furni/resync", "pets", "pets/batch", "pets/icon",
|
||||
"repair", "repair/audit",
|
||||
];
|
||||
|
||||
describe("admin import backend contract", () => {
|
||||
it.each(ROUTES)("provides and guards /api/admin/import/%s", (route) => {
|
||||
const path = `src/app/api/admin/import/${route}/route.ts`;
|
||||
expect(existsSync(path), path).toBe(true);
|
||||
const source = readFileSync(path, "utf8");
|
||||
expect(source, path).toContain("PERMS.ASSETS_IMPORT");
|
||||
});
|
||||
|
||||
it("does not leave import actions as successful no-op stubs", () => {
|
||||
const source = readFileSync("src/actions/import-furni.ts", "utf8");
|
||||
expect(source).not.toContain("deleted: 0, remaining: 0");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user