- claimOrder 状态闸门改为严格只允许 待接单(含 CAS 条件 status='待接单'),杜绝抢已在履约/已服务/已核销的订单 - getOrdersPool 仅返回未认领的 待接单 订单 - 种子数据新增一笔待接单订单用于演示抢单 - 更新/新增回归护栏 claim-status-gate.spec.ts(78 套件/608 用例全绿)
36 行
1.2 KiB
TypeScript
36 行
1.2 KiB
TypeScript
// 已读取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("'待接单');");
|
|
});
|
|
});
|