WAPC2FLIVE 创建企微审批 POC 样件
这个提交包含在:
@@ -124,6 +124,65 @@ describe("check-wecom-approval-fixtures", () => {
|
||||
expect(report.checks.fixturePayloads).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("builds create_template payload with official template_name and property controls", () => {
|
||||
const payload = buildTemplateFixturePayload(
|
||||
{ key: "leave", label: "请假" },
|
||||
"2026-05-19T10:00:00.000Z",
|
||||
);
|
||||
|
||||
expect(payload.template_names).toBeUndefined();
|
||||
expect(payload.template_name).toEqual([{ text: "OA-POC-请假-2026-05-19", lang: "zh_CN" }]);
|
||||
expect(payload.template_content.controls).toHaveLength(3);
|
||||
expect(payload.template_content.controls[0]).toMatchObject({
|
||||
property: {
|
||||
control: "Text",
|
||||
id: "Text-01",
|
||||
title: [{ text: "类型", lang: "zh_CN" }],
|
||||
placeholder: [{ text: "类型", lang: "zh_CN" }],
|
||||
require: 1,
|
||||
un_print: 1,
|
||||
},
|
||||
config: {},
|
||||
});
|
||||
expect(payload.template_content.controls[1]).toMatchObject({
|
||||
property: {
|
||||
control: "Date",
|
||||
id: "Date-01",
|
||||
},
|
||||
config: {
|
||||
date: {
|
||||
type: "day",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("builds applyevent payload with template control ids and non-self approver", () => {
|
||||
const payload = buildApplyFixturePayload({
|
||||
target: { key: "leave", label: "请假" },
|
||||
templateId: SENSITIVE_TEMPLATE_ID,
|
||||
applicantUserId: SENSITIVE_APPLICANT_USERID,
|
||||
approverUserId: SENSITIVE_APPROVER_USERID,
|
||||
generatedAt: "2026-05-19T10:00:00.000Z",
|
||||
});
|
||||
|
||||
expect(payload.creator_userid).toBe(SENSITIVE_APPLICANT_USERID);
|
||||
expect(payload.template_id).toBe(SENSITIVE_TEMPLATE_ID);
|
||||
expect(payload.use_template_approver).toBe(0);
|
||||
expect(payload.approver).toEqual([{ attr: 1, userid: [SENSITIVE_APPROVER_USERID] }]);
|
||||
expect(payload.notifyer).toEqual([SENSITIVE_APPROVER_USERID]);
|
||||
expect(payload.apply_data.contents.map((item) => item.id)).toEqual(["Text-01", "Date-01", "Textarea-01"]);
|
||||
expect(payload.apply_data.contents[1]).toMatchObject({
|
||||
control: "Date",
|
||||
value: {
|
||||
date: {
|
||||
type: "day",
|
||||
s_timestamp: "1779148800",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("does not write in live mode without the explicit env switch", async () => {
|
||||
const createTemplateImpl = vi.fn();
|
||||
const report = await executeApprovalFixtures(baseOptions({
|
||||
|
||||
在新工单中引用
屏蔽一个用户