Files
SupplierSystem/server/tests/stockBatchReportCount.test.ts

18 lines
973 B
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const query = readFileSync(new URL('../src/services/inventoryQueryService.ts', import.meta.url), 'utf8');
const inbound = readFileSync(new URL('../src/services/stockInboundService.ts', import.meta.url), 'utf8');
describe('库存列表批次报告数与生产日期默认值', () => {
it('batch_report_count 必须是真实 COUNT,不能用 EXISTS(count(*))(恒为 1 的假“存在报告”)', () => {
expect(query).toContain('SELECT count(*)::int FROM inventory_batch_report_matches m WHERE m.inventory_id = inv.id');
expect(query).not.toMatch(/EXISTS\s*\(\s*SELECT count\(\*\)::int FROM inventory_batch_report_matches/);
});
it('库存入库未填生产日期时必须保持 NULL,不默认当日', () => {
expect(inbound).not.toContain("COALESCE($6::date, (NOW() AT TIME ZONE 'Asia/Shanghai')::date)");
expect(inbound).toContain('$6::date');
});
});