83 行
2.9 KiB
TypeScript
83 行
2.9 KiB
TypeScript
import {
|
|
AiOutreachDraftService,
|
|
OutreachDraftRequest,
|
|
formatOutreachPrompt,
|
|
} from '../../../src/modules/ai/service/outreach';
|
|
|
|
describe('Point 47: AI 销售潜客智能跟进邮件/消息地道草拟引擎', () => {
|
|
let service: AiOutreachDraftService;
|
|
|
|
beforeEach(() => {
|
|
service = new AiOutreachDraftService();
|
|
});
|
|
|
|
describe('1. formatOutreachPrompt (全球商务邮件地道提示词组装)', () => {
|
|
it('英语场景应包含地道商务开场、兴趣针对性提及与日程预约呼吁', () => {
|
|
const req: OutreachDraftRequest = {
|
|
leadName: 'Arthur Pendelton',
|
|
company: 'Global Retail Alliance',
|
|
targetLanguage: 'en',
|
|
interestTopics: ['Bento Grid Micro-portal', 'Smart NFC Card'],
|
|
calendarUrl: 'https://calendar.google.com/render?action=TEMPLATE...',
|
|
tone: 'professional',
|
|
};
|
|
|
|
const prompt = formatOutreachPrompt(req);
|
|
expect(prompt).toContain('Arthur Pendelton');
|
|
expect(prompt).toContain('Global Retail Alliance');
|
|
expect(prompt).toContain('Bento Grid Micro-portal');
|
|
expect(prompt).toContain('professional');
|
|
expect(prompt).toContain('Call to Action');
|
|
});
|
|
|
|
it('阿拉伯语场景应要求符合中东商业礼仪与敬语规范', () => {
|
|
const req: OutreachDraftRequest = {
|
|
leadName: 'Sheikh Tariq Al-Mansoor',
|
|
company: 'Riyadh Holdings',
|
|
targetLanguage: 'ar',
|
|
interestTopics: ['NFC VIP Cards'],
|
|
tone: 'respectful',
|
|
};
|
|
|
|
const prompt = formatOutreachPrompt(req);
|
|
expect(prompt).toContain('Sheikh Tariq Al-Mansoor');
|
|
expect(prompt).toContain('Arabic');
|
|
expect(prompt).toContain('respectful');
|
|
});
|
|
});
|
|
|
|
describe('2. AiOutreachDraftService 草稿生成与结构化解析', () => {
|
|
it('应生成包含邮件主题、正文与预约链接的结构化草案', async () => {
|
|
const draft = await service.generateDraft({
|
|
leadName: 'Elena Rostova',
|
|
company: 'Nordic Trade Hub',
|
|
targetLanguage: 'en',
|
|
interestTopics: ['Visitor Radar CRM'],
|
|
senderName: 'Alex Zheng',
|
|
senderTitle: 'VP of International Sales',
|
|
});
|
|
|
|
expect(draft.subject).toBeDefined();
|
|
expect(draft.subject.length).toBeGreaterThan(0);
|
|
expect(draft.body).toContain('Elena Rostova');
|
|
expect(draft.body).toContain('Visitor Radar CRM');
|
|
expect(draft.body).toContain('Alex Zheng');
|
|
expect(draft.targetLanguage).toBe('en');
|
|
});
|
|
|
|
it('支持生成 WhatsApp 极简短消息格式 (short_im)', async () => {
|
|
const draft = await service.generateDraft({
|
|
leadName: 'Carlos Gomez',
|
|
company: 'Madrid Ventures',
|
|
targetLanguage: 'es',
|
|
channel: 'whatsapp',
|
|
senderName: 'Alex',
|
|
});
|
|
|
|
expect(draft.channel).toBe('whatsapp');
|
|
expect(draft.body).toContain('Carlos Gomez');
|
|
expect(draft.body.length).toBeLessThan(300); // 移动端短消息克制简洁
|
|
});
|
|
});
|
|
});
|