// 已读取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'); it('不得再用 companion_name LIKE 匹配聚合作弊式占位名', () => { expect(repoCode).not.toContain("'%我%'"); expect(repoCode).not.toContain('OR companion_name LIKE ?'); }); it('收益汇总与走势必须按档案 id / 认领用户 id 双口径统计,避免漏算', () => { const start = repoCode.indexOf('async getExpertStats('); const stats = repoCode.slice(start, start + 1600); expect(stats).toContain('resolveExpertOrderScope'); expect(stats).toContain('(expert_id = ? OR claimed_by = ?)'); // 未绑定用户的种子档案不得把档案 id 冒充用户 id 去匹配 claimed_by expect(repoCode).toContain('userId: comp.user_id != null ? Number(comp.user_id) : 0'); const trends = repoCode.slice(repoCode.indexOf('async getExpertRevenueTrends(')); expect(trends.slice(0, 6000)).toContain('(expert_id = ? OR claimed_by = ?)'); }); });