// 已读取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('登录优先按微信 openid 精确匹配', () => { const start = repoCode.indexOf('async findOrCreateUserByPhone('); expect(start).toBeGreaterThan(-1); const block = repoCode.slice(start, start + 1600); expect(block).toContain('WHERE wechat_openid = ? LIMIT 1'); // openid 查询应出现在手机号查询之前 expect(block.indexOf('wechat_openid = ?')).toBeLessThan(block.indexOf('WHERE phone = ?')); }); it('修改联系方式必须做唯一性校验', () => { const start = repoCode.indexOf('async updateUserProfile('); const block = repoCode.slice(start, start + 1500); expect(block).toContain('该联系方式已被其他账号使用'); expect(block).toContain('WHERE phone = ? AND id <> ?'); }); });