e9c3dc1120
保留 SpacetimeDB 历史表、迁移白名单与旧业务源码 切换前端 active 入口并解除旧创作页面和路由编译链 移除旧后端路由、worker 与纯业务 crate 依赖 收敛 SpacetimeDB 模块为历史数据壳 同步 Nginx、Pingora、验证门禁与架构文档
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import {
|
|
adminProfileTaskTrackingEventDefinitions,
|
|
adminTrackingEventDefinitions,
|
|
buildAdminTrackingEventKeyOptions,
|
|
filterAdminProfileTaskTrackingEventDefinitions,
|
|
filterAdminTrackingEventDefinitions,
|
|
filterAdminTrackingEventKeyOptions,
|
|
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).not.toContain('creative_agent_route_success');
|
|
expect(keys).not.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(
|
|
'work_play_start',
|
|
);
|
|
expect(options.find(({ key }) => key === 'unknown_event')?.title).toBe(
|
|
'未知事件',
|
|
);
|
|
expect(
|
|
filterAdminTrackingEventKeyOptions(options, 'work_play').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([]);
|
|
expect(findAdminTrackingEventDefinition(' daily_login ')?.title).toBe(
|
|
'每日登录',
|
|
);
|
|
});
|
|
});
|