- T1 资金/库存/报价/自采 P1(BIZ-1/2/3/4/10/13/14) - T2 主系统反向事件墓碑/改派/孤儿处理(BIZ-6/8/9) - T3 选分公司 ticket、trust proxy、角色权限收口(SEC-2/3/4) - T4 缺列/RLS/tenant 名单/FK/迁移执行器(DATA-1..8) - T5 401 登出/分页/映射口径/blob/ZIP 中文名(FE-1..4/BIZ-15) - T6 测试脚本目标守卫/config fail-fast/容器配置(OPS-2..8) - T7 前后端测试与 lint 门禁清零 - T8 应付卡片按关联订单日(口径 A) - T9 存储对象全链路归属校验、敏感列禁写、审计 target_id 超长修复
39 lines
2.0 KiB
TypeScript
39 lines
2.0 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
||
import path from 'node:path';
|
||
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* 「占坑未取得」不得静默丢单(2026-10-18 真机 `ORD_WEB_20261018_BR002_0002`:
|
||
* 一次建单中断留下空坑 ⇒ 10 分钟内该配送日所有推送被跳过且返回 200,主系统记成功、我们没导入)。
|
||
*/
|
||
const importer = readFileSync(path.join(__dirname, '../src/services/mainSystemOrderImport.ts'), 'utf8');
|
||
const routes = readFileSync(path.join(__dirname, '../src/routes/mainSystemIntegration.ts'), 'utf8');
|
||
|
||
describe('① 空坑可重占窗口:10 分钟 → 2 分钟', () => {
|
||
it('占坑 CAS 用 2 分钟陈旧判定', () => {
|
||
expect(importer).toMatch(/created_at < NOW\(\) - INTERVAL '2 minutes'/);
|
||
// 行内注释保留历史说明(10 分钟 → 2 分钟),只看 SQL 那一行
|
||
const sqlLines = importer.split('\n').filter((l) => /main_system_daily_order_imports\.created_at < NOW\(\)/.test(l));
|
||
expect(sqlLines.join('\n')).not.toMatch(/INTERVAL '10 minutes'/);
|
||
});
|
||
|
||
it('陈旧空坑被重占时必须刷新 created_at(否则第二个并发轮次会再次抢到同一坑 ⇒ 重复建单)', () => {
|
||
const start = importer.indexOf('async function claimDayOrder');
|
||
expect(start).toBeGreaterThan(-1);
|
||
const end = importer.indexOf('/**\n * 整单台账', start);
|
||
const fn = importer.slice(start, end);
|
||
const upsert = fn.slice(fn.indexOf('ON CONFLICT'), fn.indexOf('RETURNING'));
|
||
// 只改 updated_at 不够:并发轮次等锁后看到 created_at 仍是旧值会再次通过 CAS。
|
||
expect(upsert).toMatch(/created_at = NOW\(\)/);
|
||
});
|
||
});
|
||
|
||
describe('② 对方能感知"本轮没导入":503 + Retry-After', () => {
|
||
it('占坑未取得 ⇒ 503 retryable(不再 200 当成功)', () => {
|
||
expect(routes).toMatch(/import_in_flight/);
|
||
expect(routes).toMatch(/Retry-After/);
|
||
expect(routes).toMatch(/status\(503\)/);
|
||
expect(routes).toMatch(/retryable: true/);
|
||
});
|
||
});
|