feat(P19IM1-1,P19IM1-2): 新增通知渠道配置与Outbox派发
这个提交包含在:
@@ -0,0 +1,91 @@
|
||||
const {
|
||||
isImChannelTypeSupported,
|
||||
matchesNotificationChannel,
|
||||
normalizeChannelType,
|
||||
normalizeRouting,
|
||||
} = require("../../../src/services/notifications/imRouting");
|
||||
|
||||
describe("IM routing", () => {
|
||||
it("normalizes wechat_work alias to wecom", () => {
|
||||
expect(normalizeChannelType("wechat_work")).toBe("wecom");
|
||||
expect(isImChannelTypeSupported("wecom")).toBe(true);
|
||||
expect(isImChannelTypeSupported("dingtalk")).toBe(false);
|
||||
});
|
||||
|
||||
it("normalizes routing arrays and drops empty values", () => {
|
||||
expect(
|
||||
normalizeRouting({
|
||||
routing: {
|
||||
roleCodes: ["manager", "manager", ""],
|
||||
domainScopes: ["workflow", "workflow"],
|
||||
allowedTypes: ["workflow.task_assigned", ""],
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
roleCodes: ["manager"],
|
||||
domainScopes: ["workflow"],
|
||||
allowedTypes: ["workflow.task_assigned"],
|
||||
});
|
||||
});
|
||||
|
||||
it("matches channel when role scope type all hit", () => {
|
||||
const matched = matchesNotificationChannel(
|
||||
{
|
||||
enabled: true,
|
||||
channel_type: "wecom",
|
||||
config_json: {
|
||||
routing: {
|
||||
roleCodes: ["manager"],
|
||||
domainScopes: ["workflow"],
|
||||
allowedTypes: ["workflow.task_assigned"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
notificationType: "workflow.task_assigned",
|
||||
domainScope: "workflow",
|
||||
recipientRoleCodes: ["manager", "finance_mgr"],
|
||||
},
|
||||
);
|
||||
|
||||
expect(matched).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects channel when any routing dimension does not match", () => {
|
||||
const baseChannel = {
|
||||
enabled: true,
|
||||
channel_type: "wecom",
|
||||
config_json: {
|
||||
routing: {
|
||||
roleCodes: ["manager"],
|
||||
domainScopes: ["workflow"],
|
||||
allowedTypes: ["workflow.task_assigned"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(
|
||||
matchesNotificationChannel(baseChannel, {
|
||||
notificationType: "workflow.task_assigned",
|
||||
domainScope: "procurement",
|
||||
recipientRoleCodes: ["manager"],
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
matchesNotificationChannel(baseChannel, {
|
||||
notificationType: "workflow.task_assigned",
|
||||
domainScope: "workflow",
|
||||
recipientRoleCodes: ["finance_mgr"],
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
matchesNotificationChannel(baseChannel, {
|
||||
notificationType: "leave.approved",
|
||||
domainScope: "workflow",
|
||||
recipientRoleCodes: ["manager"],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户