// 已读取AGENTS.md import * as fs from 'fs'; import * as path from 'path'; /** * 第二十六批回归闸门:组局创建参数服务端校验 */ describe('第二十六批组局创建校验闸门', () => { const rootDir = path.resolve(__dirname, '../../'); const repoCode = fs.readFileSync(path.join(rootDir, 'server/src/db/repository.ts'), 'utf-8'); const block = () => { const start = repoCode.indexOf('async createActivity('); expect(start).toBeGreaterThan(-1); return repoCode.slice(start, start + 1600); }; it('付费类型/人数/费用必须服务端归一化', () => { const b = block(); expect(b).toContain('const payType = Number(data.payType) === 2 ? 2 : 1;'); expect(b).toContain('Math.min(100, Math.max(1, Math.round(rawMax)))'); expect(b).toContain('MAX_FEE_CENTS'); expect(b).toContain('const perPersonFeeCents = payType === 1 ? fee : 0;'); }); it('不得再直接信任客户端未校验费用', () => { const b = block(); expect(b).not.toContain('const perPersonFeeCents = data.perPersonFeeCents || 5000;'); expect(b).not.toContain('const maxParticipants = data.maxParticipants || 4;'); }); });