65 行
2.3 KiB
TypeScript
65 行
2.3 KiB
TypeScript
// 已读取AGENTS.md
|
|
import { ContentSecurityService } from '../src/core/security/content-security.service';
|
|
|
|
describe('场所白名单准入与敏感词内容安全审查 TDD 自动化测试', () => {
|
|
const secService = new ContentSecurityService();
|
|
|
|
it('1. 合规公开商圈场所白名单准入', () => {
|
|
const validPlace = {
|
|
name: '三里屯太二酸菜鱼',
|
|
area: '朝阳区三里屯商圈',
|
|
category: '餐饮美食',
|
|
safetyLevel: 'AAA级合规认证',
|
|
status: '正常营业'
|
|
};
|
|
|
|
expect(validPlace.name).toBe('三里屯太二酸菜鱼');
|
|
expect(validPlace.safetyLevel).toBe('AAA级合规认证');
|
|
});
|
|
|
|
it('2. 录入合规商业场所时内容安全审查放行', () => {
|
|
const check = secService.checkText('工体纯KTV 朝阳区工人体育场商圈 量贩KTV');
|
|
expect(check.pass).toBe(true);
|
|
expect(check.suggest).toBe('pass');
|
|
});
|
|
|
|
it('3. 录入涉黄低俗敏感词场所时系统自动拦截', () => {
|
|
const check = secService.checkText('某某丝袜会所 上门特殊服务');
|
|
expect(check.pass).toBe(false);
|
|
expect(check.code).toBe(87014);
|
|
expect(check.label).toBe('VULGAR_PORN');
|
|
});
|
|
|
|
it('4. 场所更新支持正常营业与暂停营业状态变更', () => {
|
|
const place = {
|
|
id: 'place_001',
|
|
name: '三里屯聚宝源铜锅涮肉',
|
|
status: '正常营业'
|
|
};
|
|
|
|
const updateStatus = (p: typeof place, newStatus: string) => {
|
|
return { ...p, status: newStatus };
|
|
};
|
|
|
|
const updated = updateStatus(place, '暂停营业');
|
|
expect(updated.status).toBe('暂停营业');
|
|
});
|
|
|
|
it('5. 移动端动态拉取合规商圈场所列表过滤正常营业项', () => {
|
|
const rawPlaces = [
|
|
{ id: '1', name: '太二酸菜鱼', area: '朝阳大悦城', status: '正常营业' },
|
|
{ id: '2', name: '纯KTV', area: '工体商圈', status: '暂停营业' },
|
|
{ id: '3', name: '跳海酒馆', area: '望京麒麟社', status: '正常营业' }
|
|
];
|
|
|
|
const activeZones = rawPlaces
|
|
.filter((p) => p.status === '正常营业')
|
|
.map((p) => `${p.area} · ${p.name}`);
|
|
|
|
expect(activeZones.length).toBe(2);
|
|
expect(activeZones).toContain('朝阳大悦城 · 太二酸菜鱼');
|
|
expect(activeZones).toContain('望京麒麟社 · 跳海酒馆');
|
|
expect(activeZones).not.toContain('工体商圈 · 纯KTV');
|
|
});
|
|
});
|