84 行
3.1 KiB
TypeScript
84 行
3.1 KiB
TypeScript
// 已读取AGENTS.md
|
|
import { ContentSecurityService } from '../src/core/security/content-security.service';
|
|
|
|
describe('平台通用配置与合规管理 TDD 自动化测试', () => {
|
|
const secService = new ContentSecurityService();
|
|
|
|
it('1. 平台默认客服与公告配置数据结构验证', () => {
|
|
const customerService = {
|
|
hotline: '400-888-6666',
|
|
hotlineDesc: '7x24h 官方客服服务热线',
|
|
wechat: 'peiwan_vip_kefu',
|
|
wechatDesc: '官方 VIP 客服微信号',
|
|
workHours: '周一至周日 00:00 - 24:00'
|
|
};
|
|
|
|
expect(customerService.hotline).toBe('400-888-6666');
|
|
expect(customerService.wechat).toBe('peiwan_vip_kefu');
|
|
|
|
const safetyNotice = {
|
|
title: '平台官方公告与指引',
|
|
points: [
|
|
'【安全履约须知】为保障搭子与陪伴师人身与财产安全,线下约局须在合规公开商业街区进行。',
|
|
'【现场核销】现场碰面后请出示 4 位数字核销码进行签到确认。',
|
|
'【平台兜底】平台提供 7x24 小时争议仲裁与资金托管保障服务,严禁脱离平台私下交易。'
|
|
]
|
|
};
|
|
|
|
expect(safetyNotice.points.length).toBe(3);
|
|
expect(safetyNotice.points[0]).toContain('公开商业街区');
|
|
});
|
|
|
|
it('2. 更新公告与客服信息时实施微信内容安全审查 (合规文本应放行)', () => {
|
|
const safeData = {
|
|
hotline: '400-999-8888',
|
|
wechat: 'peiwan_official_service',
|
|
points: ['请大家在公共场合文明约单,遵守平台履约秩序']
|
|
};
|
|
const check = secService.checkText(JSON.stringify(safeData));
|
|
expect(check.pass).toBe(true);
|
|
expect(check.suggest).toBe('pass');
|
|
});
|
|
|
|
it('3. 更新配置时拦截涉黄违规词 (security.msgSecCheck 拦截)', () => {
|
|
const vulgarConfig = {
|
|
wechat: 'fake_kefu',
|
|
content: '添加客服微信提供上门特殊服务'
|
|
};
|
|
const check = secService.checkText(JSON.stringify(vulgarConfig));
|
|
expect(check.pass).toBe(false);
|
|
expect(check.code).toBe(87014);
|
|
expect(check.label).toBe('VULGAR_PORN');
|
|
expect(check.message).toContain('上门特殊服务');
|
|
});
|
|
|
|
it('4. 更新配置时拦截欺诈导流或线下私单 (防脱离平台交易)', () => {
|
|
const fraudConfig = {
|
|
notice: '联系微信号,私下转账免手续费支持线下私单优惠'
|
|
};
|
|
const check = secService.checkText(JSON.stringify(fraudConfig));
|
|
expect(check.pass).toBe(false);
|
|
expect(check.code).toBe(87014);
|
|
expect(check.label).toBe('FRAUD_SCAM');
|
|
});
|
|
|
|
it('5. 系统配置合并与动态降级容错机制', () => {
|
|
const defaultConfigs: Record<string, any> = {
|
|
customer_service: { hotline: '400-888-6666', wechat: 'peiwan_vip_kefu' },
|
|
safety_notice: { title: '官方公告', points: ['注意安全'] }
|
|
};
|
|
|
|
const remoteConfigs: Record<string, any> = {
|
|
customer_service: { hotline: '400-123-4567', wechat: 'peiwan_kefu_02' }
|
|
};
|
|
|
|
const merged = {
|
|
...defaultConfigs,
|
|
...remoteConfigs
|
|
};
|
|
|
|
expect(merged.customer_service.hotline).toBe('400-123-4567');
|
|
expect(merged.safety_notice.title).toBe('官方公告');
|
|
});
|
|
});
|