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
+60
@@ -0,0 +1,60 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
AdminSalesScopeNotFoundError,
|
||||
adminCommunicationReadWhere,
|
||||
adminSalesDealReadWhere,
|
||||
adminSalesLeadReadWhere,
|
||||
adminSalesTaskReadWhere,
|
||||
assertAdminSalesWriteOwner,
|
||||
type AdminSalesAccessScope,
|
||||
} from "./admin-sales-access-scope.js";
|
||||
|
||||
const ownScope = {
|
||||
adminUserId: "sales-a",
|
||||
canReadAll: false,
|
||||
canWriteAll: false,
|
||||
canReadAllCommunication: false,
|
||||
} satisfies AdminSalesAccessScope;
|
||||
|
||||
describe("admin sales access scope", () => {
|
||||
it("binds own-only sales and communication queries to the current AdminUser", () => {
|
||||
expect(adminSalesLeadReadWhere(ownScope)).toEqual({
|
||||
assignedToAdminUserId: "sales-a",
|
||||
});
|
||||
expect(adminSalesDealReadWhere(ownScope)).toEqual({
|
||||
ownerAdminUserId: "sales-a",
|
||||
});
|
||||
expect(adminSalesTaskReadWhere(ownScope)).toEqual({
|
||||
assignedToAdminUserId: "sales-a",
|
||||
});
|
||||
expect(adminCommunicationReadWhere(ownScope)).toEqual({
|
||||
adminUserId: "sales-a",
|
||||
});
|
||||
});
|
||||
|
||||
it("removes owner predicates only for the matching all permissions", () => {
|
||||
const readAll = {
|
||||
...ownScope,
|
||||
canReadAll: true,
|
||||
canReadAllCommunication: true,
|
||||
};
|
||||
expect(adminSalesLeadReadWhere(readAll)).toEqual({});
|
||||
expect(adminSalesDealReadWhere(readAll)).toEqual({});
|
||||
expect(adminSalesTaskReadWhere(readAll)).toEqual({});
|
||||
expect(adminCommunicationReadWhere(readAll)).toEqual({});
|
||||
});
|
||||
|
||||
it("returns not-found semantics when an own-only actor targets another owner", () => {
|
||||
expect(() => assertAdminSalesWriteOwner("sales-b", ownScope)).toThrow(
|
||||
AdminSalesScopeNotFoundError
|
||||
);
|
||||
expect(() => assertAdminSalesWriteOwner("sales-a", ownScope)).not.toThrow();
|
||||
expect(() =>
|
||||
assertAdminSalesWriteOwner("sales-b", {
|
||||
...ownScope,
|
||||
canWriteAll: true,
|
||||
})
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user