a8c3f8cf0f
后台埋点查询支持日期筛选和导出全部模式 新增后台真实 event key 列表接口 任务配置页改用真实 user 埋点 key 候选 更新后台埋点查询文档和定向测试
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import {
|
|
adminProfileTaskTrackingEventDefinitions,
|
|
adminTrackingEventDefinitions,
|
|
buildAdminTrackingEventKeyOptions,
|
|
filterAdminProfileTaskTrackingEventDefinitions,
|
|
filterAdminTrackingEventKeyOptions,
|
|
filterAdminTrackingEventDefinitions,
|
|
findAdminTrackingEventDefinition,
|
|
} from './trackingEventDefinitions';
|
|
|
|
describe('admin tracking event definitions', () => {
|
|
test('后台埋点筛选候选包含后端通用埋点清单', () => {
|
|
const keys = adminTrackingEventDefinitions.map(
|
|
(definition) => definition.key,
|
|
);
|
|
|
|
expect(keys.length).toBeGreaterThan(40);
|
|
expect(keys).toContain('daily_login');
|
|
expect(keys).toContain('auth_login_options_view');
|
|
expect(keys).toContain('task_center_view');
|
|
expect(keys).toContain('asset_upload_ticket_create');
|
|
expect(keys).toContain('creative_agent_route_success');
|
|
expect(keys).toContain('work_play_start');
|
|
});
|
|
|
|
test('任务配置候选只开放适合个人任务的事件', () => {
|
|
expect(
|
|
adminProfileTaskTrackingEventDefinitions.map(({ key }) => key),
|
|
).toEqual(['daily_login']);
|
|
expect(
|
|
filterAdminProfileTaskTrackingEventDefinitions('').map(({ key }) => key),
|
|
).toEqual(['daily_login']);
|
|
});
|
|
|
|
test('后台埋点 key 候选从真实库响应合并静态标题', () => {
|
|
const options = buildAdminTrackingEventKeyOptions([
|
|
{
|
|
eventKey: 'work_play_start',
|
|
eventTitle: 'work_play_start',
|
|
scopeKinds: ['work', 'user'],
|
|
},
|
|
{
|
|
eventKey: 'unknown_event',
|
|
eventTitle: '未知事件',
|
|
scopeKinds: ['user'],
|
|
},
|
|
]);
|
|
|
|
expect(options.find(({ key }) => key === 'work_play_start')?.title).toBe(
|
|
'作品开始游玩',
|
|
);
|
|
expect(options.find(({ key }) => key === 'unknown_event')?.title).toBe(
|
|
'未知事件',
|
|
);
|
|
expect(
|
|
filterAdminTrackingEventKeyOptions(options, '作品').map(({ key }) => key),
|
|
).toEqual(['work_play_start']);
|
|
});
|
|
|
|
test('后台埋点筛选支持按中文名称和 key 搜索', () => {
|
|
expect(
|
|
filterAdminTrackingEventDefinitions('上传票据').map(({ key }) => key),
|
|
).toEqual(['asset_upload_ticket_create']);
|
|
expect(
|
|
filterAdminTrackingEventDefinitions('work_play').map(({ key }) => key),
|
|
).toEqual(['work_play_start']);
|
|
expect(findAdminTrackingEventDefinition(' daily_login ')?.title).toBe(
|
|
'每日登录',
|
|
);
|
|
});
|
|
});
|