acc_invoices: роль admin и переключатель роли CFO/accountant/employee; Keycloak: фирменный стиль KH Build
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
19
packages/acc_invoices/src/auth.test.ts
Normal file
19
packages/acc_invoices/src/auth.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { effectiveRoles } from "./auth.js";
|
||||
|
||||
describe("effectiveRoles", () => {
|
||||
it("CFO по умолчанию CFO и может переключаться", () => {
|
||||
expect(effectiveRoles(["cfo"])).toEqual({ roles: ["cfo"], canSwitch: true, acting: "cfo" });
|
||||
expect(effectiveRoles(["cfo"], "employee")).toEqual({ roles: [], canSwitch: true, acting: "employee" });
|
||||
expect(effectiveRoles(["cfo"], "accountant").roles).toEqual(["accountant"]);
|
||||
});
|
||||
it("admin по умолчанию employee и может стать кем угодно", () => {
|
||||
expect(effectiveRoles(["admin"])).toEqual({ roles: [], canSwitch: true, acting: "employee" });
|
||||
expect(effectiveRoles(["admin"], "cfo").roles).toEqual(["cfo"]);
|
||||
expect(effectiveRoles(["admin"], "bogus").acting).toBe("employee");
|
||||
});
|
||||
it("бухгалтер и сотрудник переключаться не могут", () => {
|
||||
expect(effectiveRoles(["accountant"], "cfo")).toEqual({ roles: ["accountant"], canSwitch: false, acting: "accountant" });
|
||||
expect(effectiveRoles([], "cfo")).toEqual({ roles: [], canSwitch: false, acting: "employee" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user