From 75953b0787003640815e493539b210ca0fb291b3 Mon Sep 17 00:00:00 2001 From: lik Date: Sun, 8 Nov 2026 12:08:02 +0800 Subject: [PATCH] =?UTF-8?q?test(agent):=20=E8=AE=A2=E5=8D=95=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=8B=92=E7=BB=9D=E7=BB=84=E5=90=88=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E4=B8=8D=E5=BA=94=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=9C=A8=E9=80=94=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关单延后到全部校验通过之后执行,这里锁定该行为:组合状态更新被拒时 不能产生关单副作用。 --- test/db_tools.test.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/db_tools.test.js b/test/db_tools.test.js index b486d27..56bd9e8 100644 --- a/test/db_tools.test.js +++ b/test/db_tools.test.js @@ -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; + } +});