29 lines
1.4 KiB
TypeScript
29 lines
1.4 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'/);
|
||
});
|
||
});
|
||
|
||
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/);
|
||
});
|
||
});
|