Files
SupplierSystem/server/tests/mainSystemImportInFlight.test.ts
T
Ubuntu ca92977b4d
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
test(主系统导入): 断言只看 SQL 行,避免被历史注释误伤
2026-10-18 15:35:49 +08:00

29 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/);
});
});