Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
import type { DbTransactionClient } from "@hivegrid/db/transactions.server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
tenantHasChatModuleForSystemTx,
|
||||
tenantHasChatModuleWithPermissionsTx,
|
||||
tenantHasFilesModuleWithPermissionsTx,
|
||||
tenantHasTasksModuleWithPermissionsTx,
|
||||
} from "./module-access.server.js";
|
||||
|
||||
describe("chat module transaction gate", () => {
|
||||
it("honors a disabled tenant override for system lifecycle hooks", async () => {
|
||||
const tx = transactionReturning([{ blueprintId: "crm-saas", tenantOverride: "disabled" }]);
|
||||
|
||||
await expect(tenantHasChatModuleForSystemTx(tx, "tenant_1")).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it("bypasses user RBAC only for the explicit system helper", async () => {
|
||||
const userTx = transactionReturning([{ blueprintId: "crm-saas", tenantOverride: "inherit" }]);
|
||||
const systemTx = transactionReturning([{ blueprintId: "crm-saas", tenantOverride: "inherit" }]);
|
||||
|
||||
await expect(tenantHasChatModuleWithPermissionsTx(userTx, "tenant_1", [])).resolves.toBe(false);
|
||||
await expect(tenantHasChatModuleForSystemTx(systemTx, "tenant_1")).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it("evaluates Files and Tasks against their own feature override in the current transaction", async () => {
|
||||
const filesTx = transactionReturning([{ blueprintId: "crm-saas", tenantOverride: "disabled" }]);
|
||||
const tasksTx = transactionReturning([{ blueprintId: "crm-saas", tenantOverride: "inherit" }]);
|
||||
|
||||
await expect(tenantHasFilesModuleWithPermissionsTx(filesTx, "tenant_1", ["files.read_own", "files.write"])).resolves.toBe(false);
|
||||
await expect(tenantHasTasksModuleWithPermissionsTx(tasksTx, "tenant_1", ["tasks.read_own", "tasks.write"])).resolves.toBe(true);
|
||||
|
||||
expect(filesTx.$queryRaw).toHaveBeenCalledOnce();
|
||||
expect(tasksTx.$queryRaw).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
function transactionReturning(rows: unknown[]): DbTransactionClient {
|
||||
return { $queryRaw: vi.fn(async () => rows) } as unknown as DbTransactionClient;
|
||||
}
|
||||
Reference in new issue
Block a user