// 已读取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 mysqlCode = fs.readFileSync(path.join(rootDir, 'server/src/db/mysql.ts'), 'utf-8'); const claimBlock = () => { const start = repoCode.indexOf('async claimOrder('); expect(start).toBeGreaterThan(-1); return repoCode.slice(start, start + 2600); }; it('仅待接单可抢单(含 CAS 条件)', () => { const b = claimBlock(); expect(b).toContain("String(cur.status) !== '待接单'"); expect(b).toContain("仅待接单可抢"); expect(b).toContain("AND status = '待接单'"); }); it('抢单池仅含待接单且未认领', () => { const start = repoCode.indexOf('async getOrdersPool('); const block = repoCode.slice(start, start + 900); expect(block).toContain("WHERE status = '待接单'"); }); it('种子数据提供一笔待接单用于演示抢单', () => { expect(mysqlCode).toContain("'待接单');"); }); });