feat: complete quality/observability/KB port batch

This commit is contained in:
wangliang
2026-10-23 11:42:51 +08:00
parent b778570045
commit f343bf1832
12 changed files with 202 additions and 2 deletions
+26
View File
@@ -0,0 +1,26 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { attachChatToOpportunity } = require('../src/chat-log');
test('chat-log: attaches full conversation as opportunity note', async () => {
const calls = [];
const client = {
async getMessages() {
return [
{ id: 1, sender_type: 'contact', text_content: 'I want 500 rings', private: false },
{ id: 2, sender_type: 'agent', text_content: '<p>Sure, here are options.</p>', private: false },
];
},
};
const twenty = {
async createNote(text) { calls.push(['note', text]); return 'note-1'; },
async linkNoteToOpportunity(note, opp) { calls.push(['link', note, opp]); },
};
const id = await attachChatToOpportunity({ client, twenty, convUuid: 'c1', opportunityId: 'o1' });
assert.equal(id, 'note-1');
assert.match(calls[0][1], /Customer\] I want 500 rings/);
assert.match(calls[0][1], /Agent\] Sure, here are options/);
assert.deepEqual(calls[1], ['link', 'note-1', 'o1']);
});