test(agent): 订单工具拒绝组合状态更新时不应关闭在途支付
关单延后到全部校验通过之后执行,这里锁定该行为:组合状态更新被拒时 不能产生关单副作用。
This commit is contained in:
@@ -14,6 +14,8 @@ import { createEscortRecordQueryTool } from "../agent/infra/tools/db/user/escort
|
||||
import { escortRecordQueryTool } from "../agent/infra/tools/db/admin/escort_record_query.js";
|
||||
import { createAttendantEscortRecordQueryTool } from "../agent/infra/tools/db/attendant/escort_record_query.js";
|
||||
import { buildAttendantEscortRecordSetTool } from "../agent/infra/tools/db/attendant/escort_record_set.js";
|
||||
import { escortRecordSetTool } from "../agent/infra/tools/db/admin/escort_record_set.js";
|
||||
import { HandlerPayment } from "../handler/payment.js";
|
||||
import { resolveEscortAdminRole } from "../utils/permissions.js";
|
||||
|
||||
const OWNER_ID = "64b000000000000000000001";
|
||||
@@ -409,3 +411,33 @@ test("历史管理员 role 缺失仍按管理员放行", async () => {
|
||||
assert.equal(legacy, "admin");
|
||||
});
|
||||
});
|
||||
|
||||
test("管理端订单工具拒绝组合状态更新前不会关闭在途支付", async () => {
|
||||
const previousClose = HandlerPayment.closeOpenPayRecords;
|
||||
let closeCalls = 0;
|
||||
HandlerPayment.closeOpenPayRecords = async () => {
|
||||
closeCalls += 1;
|
||||
return { closed: 0, paid: 0, unconfirmed: 0 };
|
||||
};
|
||||
const record = {
|
||||
_id: OWNER_ID,
|
||||
status: "confirmed",
|
||||
cancelStatus: "none",
|
||||
payment: { status: "unpaid", totalFee: 500, paidFee: 0 },
|
||||
};
|
||||
|
||||
try {
|
||||
await withModel("EscortRecord", { findById: async () => record }, async () => {
|
||||
const result = parseResult(await escortRecordSetTool.invoke({
|
||||
orderId: OWNER_ID,
|
||||
status: "in_progress",
|
||||
cancelStatus: "cancelled",
|
||||
}));
|
||||
assert.equal(result.success, false);
|
||||
assert.match(result.error, /Do not update service status and cancel status/);
|
||||
assert.equal(closeCalls, 0);
|
||||
});
|
||||
} finally {
|
||||
HandlerPayment.closeOpenPayRecords = previousClose;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user