chore: CRM-NEW baseline

This commit is contained in:
wangliang
2026-10-23 10:35:28 +08:00
commit aa499f6dbf
111 changed files with 15126 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { hasBuyingIntent, missingLeadContacts, detectLanguage, appendLeadFollowup, alreadyAsksForLead } = require('../src/lead-intent');
test('lead-intent: product + quantity is buying intent', () => {
assert.equal(hasBuyingIntent('I want 500 pieces of stainless steel rings'), true);
assert.equal(hasBuyingIntent('Do you have rings?'), false);
});
test('lead-intent: missing company/contact', () => {
assert.deepEqual(missingLeadContacts({}), ['company', 'contact']);
assert.deepEqual(missingLeadContacts({ company: 'ACME', email: 'a@b.com' }), []);
});
test('lead-intent: localized followup appended once', () => {
const lang = detectLanguage('我想采购500件戒指');
assert.equal(lang, 'zh');
const out = appendLeadFollowup('好的,这里有几款戒指。', lang);
assert.match(out, /公司名称/);
assert.equal(appendLeadFollowup(out, lang), out);
});
test('lead-intent: detects existing ask in reply', () => {
assert.equal(alreadyAsksForLead('Could you share your company name and email?'), true);
assert.equal(alreadyAsksForLead('Here are some rings.'), false);
});