Files
SupplierSystem/server/tests/inspectionStorageZone.test.ts
Ubuntu 5fa2bbfd55
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
fix(audit-20261019): T1-T9 审计修复、存储归属与审计日志列宽
- 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 超长修复
2026-10-19 16:16:51 +08:00

77 lines
3.5 KiB
TypeScript
Raw Permalink 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-13):
* 验收(含独立进货)入库存量台账时随批次写 `inventory.storage_zone`,
* 与「库存入库」面板同列同口径。区域是**自由文本**、无独立表;不填写 NULL。
*
* 设计文档:docs/design/20261013-验收入库补存放区域.md
*
* 本文件钉住:① 服务层入参与 INSERT 带 storage_zone;② 两端路由都映射入参;
* ③ 未传区域的自动/合并调用行为不变(入参可选、默认 NULL)。
*/
const readServer = (rel: string) => readFileSync(path.join(__dirname, '..', rel), 'utf8');
describe('服务层:验收入库写批次存放区域', () => {
const svc = readServer('src/services/inspectionComplianceService.ts');
it('入参新增可选 storage_zone(不填即 NULL,旧调用方不受影响)', () => {
expect(svc).toContain('storage_zone?: string | null;');
});
it('入库 INSERT 的列清单含 storage_zone,取值 trim 后空转 NULL', () => {
expect(svc).toContain('production_date, shelf_life, expiry_date, storage_zone');
expect(svc).toContain("String(input.storage_zone || '').trim() || null");
});
it('普通验收与独立进货共用同一段 INSERT(一处改动覆盖两者)', () => {
// 该 INSERT 上文按 writeStockLedger 分支;independentInbound 复用同一写入
expect(svc).toContain('const writeStockLedger =');
expect(svc).toContain('independentInbound');
});
it('不写空串:空/仅空白 ⇒ null(与库存入库同口径)', () => {
expect(svc).toContain("String(input.storage_zone || '').trim() || null");
});
});
describe('两端路由映射 storage_zone', () => {
it('Web POST /inspection/submit 透传 body.storage_zone', () => {
const web = readServer('src/modules/workflow/routes/inspectionRoutes.ts');
const start = web.indexOf("router.post('/inspection/submit'");
const end = web.indexOf("router.get('/processing/tasks'");
const submit = web.slice(start, end);
expect(submit).toContain('storage_zone: req.body?.storage_zone');
});
it('移动 POST /mobile/inspection/complete 透传 body.storage_zone', () => {
const mobile = readServer('src/routes/mobile/mobileWarehouseRoutes.ts');
const start = mobile.indexOf("router.post('/inspection/complete'");
const end = mobile.indexOf("router.get('/inspection/weigh-station/pending'");
const complete = mobile.slice(start, end);
expect(complete).toContain('storage_zone: req.body?.storage_zone');
});
});
describe('验收列表带「上次入库区域」(默认值来源)', () => {
it('移动 /inspection/tasks 查询拼上 LAST_INBOUND_ZONE 片段', () => {
const mobile = readServer('src/routes/mobile/mobileWarehouseRoutes.ts');
const start = mobile.indexOf("router.get('/inspection/tasks'");
const end = mobile.indexOf("router.post('/inspection/complete'");
const tasks = mobile.slice(start, end);
expect(tasks).toContain('LAST_INBOUND_ZONE_SELECT');
expect(tasks).toContain('LAST_INBOUND_ZONE_JOIN');
});
it('Web 列表分页拼上 LAST_INBOUND_ZONE 片段(计数/统计不拼)', () => {
const svc = readServer('src/services/inspectionQueryService.ts');
expect(svc).toContain('LAST_INBOUND_ZONE_SELECT');
expect(svc).toContain('listFromSql');
// 统计/计数仍用不带 last_zone 的 fromSql
expect(svc).toMatch(/statsRes = await pool\.query\([\s\S]*?\$\{fromSql\}/);
});
});