// 已读取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 = { customer_service: { hotline: '400-888-6666', wechat: 'peiwan_vip_kefu' }, safety_notice: { title: '官方公告', points: ['注意安全'] } }; const remoteConfigs: Record = { 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('官方公告'); }); it('6. 友圈热门话题与置顶公告配置校验 (P4)', () => { const defaultTopics = [ { name: '#深夜电台', count: '1.2w+', hot: true }, { name: '#周末密室剧本杀', count: '8.5k', hot: true }, { name: '#王者峡谷车队', count: '2.1w+', hot: false } ]; expect(defaultTopics.length).toBe(3); expect(defaultTopics.filter(t => t.hot).length).toBe(2); const notice = { tag: '头条', title: '友圈同城搭子发帖公约:严禁发布广告与不文明交友行为' }; const secResult = secService.checkText(notice.title); expect(secResult.pass).toBe(true); const badNotice = { tag: '广告', title: '添加客服微信提供上门特殊服务' }; const badSec = secService.checkText(badNotice.title); expect(badSec.pass).toBe(false); expect(badSec.code).toBe(87014); }); it('7. 帮助中心与常见问题 FAQ 配置校验 (P5)', () => { const faqList = [ { question: '如何成为认证陪伴师/陪玩大神?', answer: '进入【我的】->【入驻申请】,提交实名认证与技能资质,平台将在 24 小时内完成人工审核。', category: '陪伴师相关' }, { question: '遇到订单纠纷如何申请平台仲裁?', answer: '在【订单详情】中点击【申请仲裁退款】,客服与平台专员将在 2 小时内介入调解。', category: '订单与退款' } ]; expect(faqList.length).toBe(2); expect(faqList[0].category).toBe('陪伴师相关'); const check = secService.checkText(JSON.stringify(faqList)); expect(check.pass).toBe(true); }); });