feat(P15A-1,P15A-5): 解耦请假审批权限
这个提交包含在:
@@ -0,0 +1,53 @@
|
||||
const workflowRoutes = require("../../../src/routes/workflow");
|
||||
|
||||
describe("Workflow Route Permissions", () => {
|
||||
const { listAllowedActionsForTask } = workflowRoutes.__testables;
|
||||
|
||||
it("allows leave approvers to act on leave tasks", () => {
|
||||
const actions = listAllowedActionsForTask(
|
||||
{ employee: { permissionCodes: ["leave.approve"] } },
|
||||
{
|
||||
status: "pending",
|
||||
workflow_instance: { entity_type: "leave" },
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
expect(actions).toEqual(["approve", "reject", "return"]);
|
||||
});
|
||||
|
||||
it("does not allow expense approvers to act on leave tasks without leave.approve", () => {
|
||||
const actions = listAllowedActionsForTask(
|
||||
{ employee: { permissionCodes: ["expense.approve"] } },
|
||||
{
|
||||
status: "pending",
|
||||
workflow_instance: { entity_type: "leave" },
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps transfer action limited to reimbursement tasks", () => {
|
||||
const reimbursementActions = listAllowedActionsForTask(
|
||||
{ employee: { permissionCodes: ["expense.approve", "expense.transfer"] } },
|
||||
{
|
||||
status: "pending",
|
||||
workflow_instance: { entity_type: "reimbursement" },
|
||||
},
|
||||
true,
|
||||
);
|
||||
const leaveActions = listAllowedActionsForTask(
|
||||
{ employee: { permissionCodes: ["leave.approve", "expense.transfer"] } },
|
||||
{
|
||||
status: "pending",
|
||||
workflow_instance: { entity_type: "leave" },
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
expect(reimbursementActions).toContain("transfer");
|
||||
expect(leaveActions).not.toContain("transfer");
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户