ForgeFlow-ERP/frontend/scripts/test-production-work-order-inbound-ui.mjs
2026-06-12 16:00:56 +08:00

44 lines
2.5 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const inventoryView = readFileSync(new URL("../src/views/InventoryLedgerView.vue", import.meta.url), "utf8");
const stockLotSelect = readFileSync(new URL("../src/components/StockLotTagSelect.vue", import.meta.url), "utf8");
const systemExtension = readFileSync(new URL("../src/views/SystemExtensionView.vue", import.meta.url), "utf8");
assert.match(stockLotSelect, /maxSelections/);
assert.match(inventoryView, /生产台账入库/);
assert.match(inventoryView, /一次生产出库只能选择一个材料库存批次号/);
assert.match(inventoryView, /production-ledger-inbounds\/preview/);
assert.match(inventoryView, /production-ledger-inbounds/);
assert.match(inventoryView, /本次入库后该批材料结单/);
assert.match(
inventoryView,
/<input[\s\S]*?v-model\.number="productionWorkOrderInboundForm\.finished_qty"[\s\S]*?@input="handleProductionWorkOrderInboundFinishedQtyInput"/,
"生产台账入库的成品数量必须在输入时即时刷新理论余料和理论废料"
);
assert.doesNotMatch(
inventoryView,
/<input[\s\S]*?v-model\.number="productionWorkOrderInboundForm\.finished_qty"[\s\S]*?@change="loadProductionWorkOrderInboundPreview\(true\)"/,
"生产台账入库的成品数量不能依赖 change/失焦后才刷新理论指标"
);
assert.match(inventoryView, /参考成品数量/);
assert.match(inventoryView, /reference_finished_qty/);
assert.match(inventoryView, /以下指标超过15%导致异常/);
assert.match(inventoryView, /成品入库数量超过本生产台账参考生产数量上限15%/);
assert.match(inventoryView, /余料入库重量与理论值偏差超过上下15%/);
assert.match(inventoryView, /废料重量与理论值偏差超过上下15%/);
assert.doesNotMatch(
inventoryView,
/<label class="form-field">\s*<span>偏差说明<\/span>\s*<textarea[\s\S]*?productionWorkOrderInboundForm\.deviation_remark/,
"生产台账入库偏差说明不能常驻显示,必须在异常确认后弹出填写"
);
assert.match(
inventoryView,
/const confirmed = window\.confirm\(buildProductionWorkOrderInboundConfirmMessage\([\s\S]*?if \(!ensureProductionWorkOrderInboundDeviationRemark\(\)\)/,
"生产台账入库必须先弹入库明细确认,再在异常时弹出偏差说明"
);
assert.match(systemExtension, /原材料库存批次号前缀/);
assert.match(systemExtension, /raw-material-lot-prefix/);
console.log("production work-order inbound UI checks passed");