49 lines
1.9 KiB
JavaScript
49 lines
1.9 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("dimension asterisks stay visible in group markdown", () => {
|
|
const frame = buildGroupMessageFrame({
|
|
chatId: "wr_1",
|
|
content: "体积(CBM)(必填):1.1*2.1*2.1",
|
|
callbackReqId: "",
|
|
});
|
|
assert.equal(frame.body.markdown.content, "体积(CBM)(必填):`1.1*2.1*2.1`");
|
|
const again = buildGroupMessageFrame({
|
|
chatId: "wr_1",
|
|
content: frame.body.markdown.content,
|
|
callbackReqId: "",
|
|
});
|
|
assert.equal(again.body.markdown.content, "体积(CBM)(必填):`1.1*2.1*2.1`");
|
|
});
|
|
|
|
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: "" }), "");
|
|
});
|
|
|