28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { PERMS } from "@/lib/permission-slugs";
|
|
|
|
describe("production ACL migration", () => {
|
|
const migrationPath = resolve(process.cwd(), "prisma/migrations/0012_seed_acl_permissions.sql");
|
|
|
|
it("seeds every permission used by the application", () => {
|
|
const sql = readFileSync(migrationPath, "utf8");
|
|
|
|
for (const slug of Object.values(PERMS)) {
|
|
expect(sql, `missing ACL seed for ${slug}`).toContain(`'${slug}'`);
|
|
}
|
|
});
|
|
|
|
it("assigns dashboard access after seeding permissions", () => {
|
|
const sql = readFileSync(migrationPath, "utf8");
|
|
const seedPosition = sql.indexOf("INSERT INTO `acl_permissions`");
|
|
const assignmentPosition = sql.indexOf("INSERT INTO `acl_model_permissions`");
|
|
|
|
expect(seedPosition).toBeGreaterThanOrEqual(0);
|
|
expect(assignmentPosition).toBeGreaterThan(seedPosition);
|
|
expect(sql).toContain("ap.slug = 'admin.dashboard'");
|
|
expect(sql).toContain("ap.slug = 'mod.dashboard'");
|
|
});
|
|
});
|