refactor(i18n): 全工程面向国际用户与全球现代商务重构,彻底清理出海跨境等单向视角表达并对齐自动化测试
这个提交包含在:
@@ -1,6 +1,7 @@
|
||||
import { AdminCrmRadarController } from '../../../src/modules/crm/controller/admin/radar';
|
||||
import {
|
||||
buildWorkplaceOverview,
|
||||
calculateTrackIntentScore,
|
||||
CrmRadarService,
|
||||
} from '../../../src/modules/crm/service/radar';
|
||||
import { CrmTrackEntity } from '../../../src/modules/crm/entity/track';
|
||||
@@ -152,4 +153,97 @@ describe('商务概览工作台聚合 (getWorkplaceOverview)', () => {
|
||||
expect(res.data.kpis.viewCount).toBe(2);
|
||||
expect(controller.crmRadarService.getWorkplaceOverview).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('数据专家重构:科学意向度与会话降噪增强', () => {
|
||||
it('科学意向分算法 (calculateTrackIntentScore) 必须符合多因子阶梯模型', () => {
|
||||
// 1. 直链 0 秒跳出,无任何浏览与滚动:低意向分 (10分)
|
||||
const bounceScore = calculateTrackIntentScore({
|
||||
touchType: 'link',
|
||||
stayDurationMs: 0,
|
||||
scrollDepth: 0,
|
||||
viewedBlocks: [],
|
||||
});
|
||||
expect(bounceScore).toBe(10);
|
||||
|
||||
// 2. NFC 面对面触碰初始分:天然高权重 (35分)
|
||||
const nfcInitialScore = calculateTrackIntentScore({
|
||||
touchType: 'nfc',
|
||||
stayDurationMs: 0,
|
||||
});
|
||||
expect(nfcInitialScore).toBe(35);
|
||||
|
||||
// 3. QR 扫码 + 30秒研读 + 2个模块 + 深度滚动:高意向买家 (25 + 20 + 10 + 10 = 65分)
|
||||
const engagedScore = calculateTrackIntentScore({
|
||||
touchType: 'qr',
|
||||
stayDurationMs: 30000,
|
||||
viewedBlocks: ['hero', 'products'],
|
||||
scrollDepth: 75,
|
||||
});
|
||||
expect(engagedScore).toBe(65);
|
||||
|
||||
// 4. NFC 触碰 + 150秒深读 + 4个模块 + 深度滚动:极高意向买家 (封顶 99分)
|
||||
const hotScore = calculateTrackIntentScore({
|
||||
touchType: 'nfc',
|
||||
stayDurationMs: 150000,
|
||||
viewedBlocks: ['hero', 'products', 'cases', 'contact'],
|
||||
scrollDepth: 95,
|
||||
});
|
||||
expect(hotScore).toBe(99);
|
||||
});
|
||||
|
||||
it('buildWorkplaceOverview 应实现会话去噪与合并,并填充名片名称和本地标记', () => {
|
||||
const cardList = [
|
||||
{ id: 1, name: 'Alex Chen', title: '全球商务总监' },
|
||||
];
|
||||
|
||||
// 同一访客 vis_101 先产生了 0 秒 PV,又更新了 45 秒有效停留
|
||||
const t1 = track({
|
||||
id: 10,
|
||||
cardId: 1,
|
||||
touchType: 'link',
|
||||
country: 'Local',
|
||||
city: 'Local',
|
||||
stayDurationMs: 0,
|
||||
createTime: new Date('2026-09-21T10:00:00'),
|
||||
});
|
||||
t1.visitorId = 'vis_101';
|
||||
|
||||
const t2 = track({
|
||||
id: 11,
|
||||
cardId: 1,
|
||||
touchType: 'link',
|
||||
country: 'Local',
|
||||
city: 'Local',
|
||||
stayDurationMs: 45000,
|
||||
viewedBlocks: ['products'],
|
||||
createTime: new Date('2026-09-21T10:01:00'),
|
||||
});
|
||||
t2.visitorId = 'vis_101';
|
||||
|
||||
const result = buildWorkplaceOverview(
|
||||
[t1, t2],
|
||||
[],
|
||||
now,
|
||||
10,
|
||||
cardList
|
||||
);
|
||||
|
||||
// 验证 1:去噪合并后同一会话只保留 1 条记录
|
||||
expect(result.radarFeed).toHaveLength(1);
|
||||
const feedItem = result.radarFeed[0];
|
||||
|
||||
// 验证 2:停留时长采用合并后的最高值 45 秒
|
||||
expect(feedItem.stayDurationMs).toBe(45000);
|
||||
expect(feedItem.viewedBlocks).toContain('products');
|
||||
|
||||
// 验证 3:名片名称正确注入
|
||||
expect(feedItem.cardTitle).toBe('Alex Chen · 全球商务总监');
|
||||
|
||||
// 验证 4:识别为本地环境
|
||||
expect(feedItem.isLocal).toBe(true);
|
||||
|
||||
// 验证 5:意向分由后端自动算出并大于 0 秒跳出分
|
||||
expect(feedItem.intentScore).toBeGreaterThan(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户