Files
SupplierSystem/server/tests/mpProcessingStandaloneStart.test.ts
雨天 308afff5ad
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
独立加工:修小程序成品申报与批次继承
- 小程序「开始加工」不再被「待完成到货验收」拦住(独立加工没有验收行)
- 成品搜索框补 data 声明并加 || '' 兜底,改为打开即载入候选 + 本地优先过滤
- 成品批次继承原料的生产日期/保质期原文/有效期/产地,入库后仍可在库存管理修改
- 两个继承开关默认勾选,选中态改绿色实心勾(小程序自绘,Web 用 accent)
- 新增两篇设计文档并同步索引
2026-10-23 17:04:20 +08:00

51 lines
2.0 KiB
TypeScript

import { readFileSync } from 'fs';
import { describe, expect, it } from 'vitest';
/**
* 小程序「加工」面板:独立加工必须能直接开始(申报成品),不能因为「没有验收行」被拦住。
*
* 真机问题(2026-10-23):Web 端「待加工」有「开始加工」,小程序同一单却显示
* 「待完成到货验收后可开始加工」且没有按钮。
* 根因:独立加工单 `inspection_id` 为 NULL(创建时显式写 NULL),`inspection_completed`
* 恒为 false;小程序用它当开工门槛,而后端 `startProcessingTask` 只在
* 「inspection_id 存在且 inspection_time 为空」时才拦。
*/
const panelJs = readFileSync(
new URL('../../miniprogram/components/processing-panel/index.js', import.meta.url),
'utf8'
);
const panelWxml = readFileSync(
new URL('../../miniprogram/components/processing-panel/index.wxml', import.meta.url),
'utf8'
);
const taskService = readFileSync(
new URL('../src/services/processingTaskService.ts', import.meta.url),
'utf8'
);
const standaloneService = readFileSync(
new URL('../src/services/processingStandaloneService.ts', import.meta.url),
'utf8'
);
describe('小程序加工:独立加工开工门槛与后端一致', () => {
it('独立加工单创建时 inspection_id 为 NULL(所以不存在“到货验收”这一步)', () => {
expect(standaloneService).toContain("VALUES (NULL, NULL, $1, 'standalone'");
});
it('后端只在「有 inspection_id 且未验收」时拦开工', () => {
expect(taskService).toContain(
'if (current.rows[0].inspection_id && current.rows[0].inspection_time == null)'
);
});
it('小程序 can_start_work 对独立加工放行', () => {
expect(panelJs).toContain("const isStandalone = row.source_type === 'standalone'");
expect(panelJs).toContain('(isStandalone || row.inspection_completed === true)');
});
it('「待完成到货验收」提示不再出现在独立加工上', () => {
expect(panelWxml).toContain('!item.is_standalone && !item.inspection_completed');
});
});