fix: 整合本地单据校验与离线身份修复
从旧审查分支选择仍未进入主分支的单据修复,保留主分支较新的工作流与插件分发实现。 兼容费用类型包装树,统一创建预演与执行,修正核销净支付,并将真实规格校验接入复制及送审。 注册 whoami 离线参数,补充写入契约和完整入口回归,保留旧分支与工作区。 验证:bun test 876 pass / 0 fail;bun run check、check:version、git diff --check 通过。
This commit is contained in:
1 parent
c2d36733fb
commit
ebeec98f6d
12 files changed
+369
-54
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { handleCreate } from "./create.js";
|
||||
import { parseArgs } from "../../parser.js";
|
||||
|
||||
test("create dry-run resolves the same available fee as execution and never posts", async () => {
|
||||
const writes: any[] = [];
|
||||
const client = {
|
||||
get: (url: string) => ({ json: async () => url.includes("specifications/")
|
||||
? { items: [{ id: "spec", name: "模板", components: [{ field: "title" }] }] }
|
||||
: url.includes("staffs/me") ? { value: { staff: { id: "staff", defaultDepartment: "dept" } } }
|
||||
: { items: [{ feeType: { id: "travel", name: "差旅", expenseSpecificationId: "detail" }, children: [] }] } }),
|
||||
post: (_: string, payload: any) => { writes.push(payload.json); return { json: async () => ({ flow: { id: "new" } }) }; },
|
||||
};
|
||||
const base = ["bill", "create", "--template", `spec:${"a".repeat(32)}`, "--json"];
|
||||
const context = (args: string[]) => ({ parsed: parseArgs(args), runtime: { jsonMode: true }, corpId: "corp", getClient: async () => client, requireWriteConfirmation: async () => {} }) as any;
|
||||
const preview = await handleCreate(context([...base, "--dry-run"]));
|
||||
expect(JSON.parse(preview.stdout)).toMatchObject({ dryRun: true, feeType: "差旅" });
|
||||
expect(writes).toEqual([]);
|
||||
await handleCreate(context([...base, "--yes"]));
|
||||
expect(writes[0].form.details[0].feeTypeId).toBe("travel");
|
||||
await expect(handleCreate(context([...base, "--fee-type", "不存在", "--dry-run"]))).rejects.toThrow("费用类型");
|
||||
expect(writes).toHaveLength(1);
|
||||
});
|
||||
Reference in new issue
Block a user