fix: 补齐候选诊断环境与证据保护(09-06-release-gate-integrity)

这个提交包含在:
2026-09-08 07:21:19 +08:00
父节点 66f25b1fa8
当前提交 99167127b5
共修改 33 个文件,包含 2915 行新增和 67 行删除
@@ -0,0 +1,31 @@
const { ensureNonNegativeAmount } = require("../../../src/routes/reimbursements").__testables;
const { AppError } = require("../../../src/utils/AppError");
describe("reimbursement total amount defense", () => {
function assertRejected(value, detail, reasonCode) {
let caught;
try {
ensureNonNegativeAmount(value);
} catch (error) {
caught = error;
}
expect(caught).toBeInstanceOf(AppError);
expect(caught).toMatchObject({
code: "VALID_001",
statusCode: 400,
details: { total_amount: detail, reasonCode },
});
}
it.each([-1, "-0.01", -Number.MIN_VALUE])("directly rejects negative total %s", (value) => {
assertRejected(value, "negative_not_allowed", "reimbursement.total_amount_negative_not_allowed");
});
it.each([NaN, Infinity, -Infinity, "not-a-number", undefined])("directly rejects non-finite total %s", (value) => {
assertRejected(value, "invalid", "reimbursement.total_amount_invalid");
});
it.each([0, "0.00", 1, "188.80"])("preserves acceptance of finite nonnegative total %s", (value) => {
expect(() => ensureNonNegativeAmount(value)).not.toThrow();
});
});