refactor: reduce approval context overhead
CI / Client installer (macos-latest) (push) Canceled after 0s
CI / Client installer (ubuntu-latest) (push) Canceled after 0s
CI / Client installer (windows-latest) (push) Canceled after 0s
CI / test (22) (push) Canceled after 0s
CI / test (24) (push) Canceled after 0s
CI / release-smoke (push) Canceled after 0s
CI / Client installer (macos-latest) (push) Canceled after 0s
CI / Client installer (ubuntu-latest) (push) Canceled after 0s
CI / Client installer (windows-latest) (push) Canceled after 0s
CI / test (22) (push) Canceled after 0s
CI / test (24) (push) Canceled after 0s
CI / release-smoke (push) Canceled after 0s
This commit is contained in:
+12
-6
@@ -140,8 +140,11 @@ test("unified approval API returns opaque user-bound IDs and routes DingTalk act
|
||||
const listed = await service.listTodos(user, "all", 50);
|
||||
const approvalId = String(listed.items[0]!.approvalId);
|
||||
assert.deepEqual(listed.items[0]!.amount, { value: 100, currency: "CNY" });
|
||||
assert.equal(listed.items[0]!.submittedAtLocal, "2026-08-11T09:00:00.000+08:00");
|
||||
assert.equal(listed.items[0]!.submittedTimeZone, "Asia/Shanghai");
|
||||
assert.equal(listed.items[0]!.submittedAt, "2026-08-11T09:00:00.000+08:00");
|
||||
assert.equal("submittedAtLocal" in listed.items[0]!, false);
|
||||
assert.equal("submittedTimeZone" in listed.items[0]!, false);
|
||||
assert.equal("sourceType" in listed.items[0]!, false);
|
||||
assert.equal("actionsHint" in listed.items[0]!, false);
|
||||
assert.match(approvalId, /^v4\./);
|
||||
assert.ok(approvalId.length <= 128, `common DingTalk approvalId should be compact, got ${approvalId.length} characters`);
|
||||
assert.doesNotMatch(approvalId, /instance-secret|task-secret/);
|
||||
@@ -247,12 +250,15 @@ test("combined todo lists are deterministic regardless of source response timing
|
||||
} as unknown as ApprovalService;
|
||||
const xft = {
|
||||
async listMyTodos() {
|
||||
return { items: [{ source: "xft", billId: "2026081300000001", title: "XFT" }] };
|
||||
return { items: [{ source: "xft", billId: "2026081300000001", title: "XFT", applyTime: "2026-08-13T01:30:00.000Z" }] };
|
||||
},
|
||||
};
|
||||
const service = new UnifiedApprovalService(config(), ding, xft as never);
|
||||
const listed = await service.listTodos({ userId: "user-1" }, "all", 2);
|
||||
assert.deepEqual(listed.items.map((item) => item.source), ["dingtalk", "xft"]);
|
||||
assert.equal(listed.items[1]!.submittedAt, "2026-08-13T09:30:00.000+08:00");
|
||||
assert.equal("submittedAtLocal" in listed.items[1]!, false);
|
||||
assert.equal("submittedTimeZone" in listed.items[1]!, false);
|
||||
});
|
||||
|
||||
test("v4 references remain backward compatible with unexpired v2 and v3 approvals", async () => {
|
||||
@@ -309,8 +315,8 @@ test("v4 approval references stay compact for representative DingTalk, Yida, and
|
||||
};
|
||||
const service = new UnifiedApprovalService(config(), ding, xft as never);
|
||||
const listed = await service.listTodos({ userId: "user-1" }, "all", 10);
|
||||
const official = String(listed.items.find((item) => item.sourceType === "official_oa")?.approvalId);
|
||||
const yida = String(listed.items.find((item) => item.sourceType === "yida")?.approvalId);
|
||||
const official = String(listed.items.find((item) => item.businessNo === "5VXimwfMSBSWhjzttVCyWA10041785394274")?.approvalId);
|
||||
const yida = String(listed.items.find((item) => item.businessNo === "FINST-7b7ffc7800d942b7b8f6e70e16efab34")?.approvalId);
|
||||
const xftId = String(listed.items.find((item) => item.source === "xft")?.approvalId);
|
||||
assert.match(official, /^v4\./);
|
||||
assert.ok(official.length <= 128, `DingTalk reference is ${official.length} characters`);
|
||||
@@ -589,7 +595,7 @@ test("unified OA return signs live targets, revalidates them, and confirms task
|
||||
const user = { userId: "user-1", name: "测试用户乙" };
|
||||
const listed = await service.listTodos(user, "dingtalk", 10);
|
||||
assert.deepEqual(listed.items[0]!.availableActions, ["approve", "reject"]);
|
||||
assert.match(String(listed.items[0]!.actionsHint), /approval_get_actions/);
|
||||
assert.equal("actionsHint" in listed.items[0]!, false);
|
||||
const approvalId = String(listed.items[0]!.approvalId);
|
||||
const actions = await service.getActions(user, approvalId);
|
||||
const returnAction = actions.actions[2]! as {
|
||||
|
||||
Reference in New Issue
Block a user