Files
SupplierSystem/server/tests/nonJinInboundQty.test.ts
T
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

100 lines
4.1 KiB
TypeScript

import { readFileSync } from 'node:fs';
import path from 'path';
import { describe, expect, it } from 'vitest';
import { getPromptDefault } from '../src/prompts/defaults';
describe('安卓入库非斤单位不入重量', () => {
it('提示词登记进统一 registry,且包含数量识别规则', () => {
const catalog = getPromptDefault('weigh.recognize.open');
expect(catalog).toBeTruthy();
expect(catalog!.wired).toBe(true);
expect(catalog!.systemTemplate).toContain('"qty":数字或null');
expect(catalog!.systemTemplate).toContain('"unit":"单位或null"');
expect(catalog!.systemTemplate).toContain('计数单位');
expect(catalog!.systemTemplate).toContain('禁止编造');
const inbound = getPromptDefault('weigh.recognize.catalog_inbound');
expect(inbound).toBeTruthy();
expect(inbound!.wired).toBe(true);
});
it('weighStationService 走 resolvePrompt,无硬编码提示词,响应透传 suggested_qty/unit', () => {
const src = readFileSync(
path.join(__dirname, '../src/services/weighStationService.ts'),
'utf8'
);
expect(src).toContain("resolvePrompt('weigh.recognize.open'");
expect(src).toContain("resolvePrompt('weigh.recognize.catalog_inbound'");
expect(src).toContain('suggested_qty');
expect(src).toContain('suggested_unit');
// 不再残留硬编码长提示词
expect(src).not.toContain('你是生鲜称重台商品识别与质量验收助手');
expect(src).not.toContain('你是生鲜仓库独立入库识别与质量验收助手');
});
it('/inspection/complete 接可选 actual_weight;小程序不传则为 null', () => {
const route = readFileSync(
path.join(__dirname, '../src/routes/mobile/mobileWarehouseRoutes.ts'),
'utf8'
);
expect(route).toContain('actual_weight');
// 可选解析:undefined/null/'' → null
expect(route).toContain("actualWeightRaw === undefined");
// 仅 >0 才传给 service
expect(route).toContain('actualWeight as number) > 0');
const svc = readFileSync(
path.join(__dirname, '../src/services/inspectionComplianceService.ts'),
'utf8'
);
expect(svc).toContain('actual_weight?: number | null');
expect(svc).toContain('actual_weight = $17');
// actual_weight 不参与校验/金额:落库为 NULL 或正数
expect(svc).toContain('Number(input.actual_weight) > 0');
});
it('inspections 迁移:actual_weight 可空列', () => {
const mig = readFileSync(
path.join(__dirname, '../../migrations/20260829_inspection_actual_weight.sql'),
'utf8'
);
expect(mig).toContain('ADD COLUMN IF NOT EXISTS actual_weight');
expect(mig).not.toContain('NOT NULL');
});
it('安卓端:非斤禁自动提交 + 弹窗确认件数 + actualWeight 双参数', () => {
const api = readFileSync(
path.join(
__dirname,
'../../android-weigh-terminal/app/src/main/java/com/canteen/weigh/api/InspectionApi.java'
),
'utf8'
);
expect(api).toContain('double actualWeight');
expect(api).toContain('if (actualWeight > 0)');
expect(api).toContain('body.put("actual_weight", actualWeight)');
const act = readFileSync(
path.join(
__dirname,
'../../android-weigh-terminal/app/src/main/java/com/canteen/weigh/ui/InspectionWeighActivity.java'
),
'utf8'
);
// 非斤禁自动提交
expect(act).toContain('if (!WeighStationMatcher.isWeightUnit(item.unit)) return;');
// 非斤弹窗
expect(act).toContain('confirmSubmitCounting');
expect(act).toContain('秤上参考重量');
// 非斤单位提交按钮无需秤重也可点(弹窗确认件数)
expect(act).toContain('countingUnit || settlement > 0');
// 换商品/入库完成时清空 AI 数量,避免串单
expect(act).toContain('lastSuggestedQty = null;');
// doSubmit 双参数:actualQty + actualWeightJin
expect(act).toContain('doSubmit(final InspectionTask task, String quality, final double actualQty, final double actualWeightJin');
// AI 识别数量字段
expect(act).toContain('lastSuggestedQty');
expect(act).toContain('suggested_qty');
});
});