Files
inquiry_robot/aibot-bridge/tests/group_message_frame.test.cjs
T
jillion886andCursor cfbce2fd69 落地空运单聊询价字段与线路选择。
必填核对后再建单;多条线路走 H5 点选;费用只展示该线路 TMS 回包,不套用整单空运费。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-22 15:02:32 +08:00

34 lines
1.3 KiB
JavaScript

const test = require("node:test");
const assert = require("node:assert/strict");
const { buildGroupMessageFrame, pickReplyReqId } = require("../group_message_frame.cjs");
test("group reply never uses stream", () => {
const withCb = buildGroupMessageFrame({
chatId: "wr_1",
content: "工单号:WO202609210001",
callbackReqId: "cb_1",
});
assert.notEqual(withCb.body.msgtype, "stream");
assert.equal(withCb.body.msgtype, "markdown");
assert.equal(withCb.cmd, "aibot_respond_msg");
assert.equal(withCb.body.chatid, "wr_1");
assert.equal(withCb.body.markdown.feedback, undefined);
const proactive = buildGroupMessageFrame({
chatId: "wr_1",
content: "附件已保存",
callbackReqId: "",
});
assert.equal(proactive.cmd, "aibot_send_msg");
assert.equal(proactive.body.msgtype, "markdown");
assert.equal(proactive.body.markdown.feedback, undefined);
});
test("reply req id falls back to last inbound when chat map misses", () => {
assert.equal(pickReplyReqId({ fromCaller: "cb_1", fromChat: "old", lastAny: "any" }), "cb_1");
assert.equal(pickReplyReqId({ fromCaller: "", fromChat: "chat_cb", lastAny: "any" }), "chat_cb");
assert.equal(pickReplyReqId({ fromCaller: "", fromChat: "", lastAny: "jeD_msF" }), "jeD_msF");
assert.equal(pickReplyReqId({ fromCaller: "", fromChat: "", lastAny: "" }), "");
});