实现 B-2a 报销审批内容工作台(reimbursement-approval-content-workbench)

这个提交包含在:
2026-09-01 20:32:34 +08:00
父节点 4c8ee07abb
当前提交 c840574d36
共修改 36 个文件,包含 2271 行新增和 91 行删除
@@ -36,18 +36,33 @@ async function buildApp(options = {}) {
entity_id: "44444444-4444-4444-8444-444444444444",
current_status: "pending",
current_step_id: "approval_1_finance",
context_data: {
context_data: options.contextData ?? {
standardViolations: [
{
itemId: "item-1",
expenseTypeId: "66666666-6666-4666-8666-666666666666",
expenseTypeName: "交通费",
amount: "180.00",
standardId: "77777777-7777-4777-8777-777777777777",
standardName: "交通费上限",
maxAmount: "120.00",
perUnit: "item",
exceededAmount: "60.00",
controlMode: "warn",
scopeType: "global",
scopeKey: null,
exceeded: true,
secretNestedField: "must-not-be-projected",
},
],
budgetCheck: {
budgetId: "55555555-5555-4555-8555-555555555555",
budgetCode: "BUDGET-2026",
controlMode: "warn",
usagePercent: 82.5,
exceededThreshold: true,
exceededBudget: false,
},
},
started_at: new Date("2026-04-08T08:00:00.000Z"),
completed_at: null,
@@ -128,6 +143,82 @@ describe("workflow task detail route", () => {
exceededAmount: "60.00",
}),
]);
expect(response.json().data.workflowInstance.contextData.standardViolations[0]).not.toHaveProperty("secretNestedField");
await app.close();
});
it("projects the allowed budget snapshot fields", async () => {
const { app } = await buildApp();
const response = await app.inject({ method: "GET", url: `/api/workflow/tasks/${TASK_ID}` });
expect(response.statusCode).toBe(200);
expect(response.json().data.workflowInstance.contextData).toEqual(expect.objectContaining({
budgetCheck: {
budgetId: "55555555-5555-4555-8555-555555555555",
budgetCode: "BUDGET-2026",
controlMode: "warn",
usagePercent: 82.5,
exceededThreshold: true,
exceededBudget: false,
},
budgetCheckStatus: "available",
parseStatus: "ready",
}));
await app.close();
});
it("marks a historical missing budget snapshot without failing parsing", async () => {
const { app } = await buildApp({ contextData: { standardViolations: [] } });
const response = await app.inject({ method: "GET", url: `/api/workflow/tasks/${TASK_ID}` });
expect(response.json().data.workflowInstance.contextData).toEqual({
standardViolations: [],
budgetCheck: null,
budgetCheckStatus: "missing",
parseStatus: "ready",
});
await app.close();
});
it("distinguishes a recorded submission with no applicable budget from historical missing data", async () => {
const { app } = await buildApp({ contextData: { standardViolations: [], budgetCheck: null, budgetCheckRecorded: true } });
const response = await app.inject({ method: "GET", url: `/api/workflow/tasks/${TASK_ID}` });
expect(response.json().data.workflowInstance.contextData).toEqual({
standardViolations: [],
budgetCheck: null,
budgetCheckStatus: "not_applicable",
parseStatus: "ready",
});
await app.close();
});
it("fails the snapshot projection closed when stored fields are malformed", async () => {
const { app } = await buildApp({
contextData: {
standardViolations: { itemId: "not-an-array" },
budgetCheck: { budgetCode: "BUDGET-2026", usagePercent: "unknown" },
secretField: "must-not-be-projected",
},
});
const response = await app.inject({ method: "GET", url: `/api/workflow/tasks/${TASK_ID}` });
const contextData = response.json().data.workflowInstance.contextData;
expect(contextData).toEqual({
standardViolations: [],
budgetCheck: null,
budgetCheckStatus: "missing",
parseStatus: "invalid",
});
expect(contextData).not.toHaveProperty("secretField");
await app.close();
});