ForgeFlow-ERP/frontend/scripts/test-scrap-sale-out-source-lots.mjs
2026-06-12 16:00:56 +08:00

51 lines
1.8 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
const inventoryViewSource = readFileSync(
fileURLToPath(new URL("../src/views/InventoryLedgerView.vue", import.meta.url)),
"utf8"
);
const backendInventorySource = readFileSync(
fileURLToPath(new URL("../../backend/app/api/routes/inventory.py", import.meta.url)),
"utf8"
);
assert.match(
inventoryViewSource,
/const isScrapSaleOutbound = computed\(\(\) =>[\s\S]*activeWarehouseType\.value === "SCRAP"[\s\S]*activeOperation\.value\?\.bizType === "SCRAP_SALE_OUT"/,
"scrap sale outbound should have an explicit state flag"
);
assert.match(
inventoryViewSource,
/if \(isScrapSaleOutbound\.value\) \{[\s\S]*return "废料";[\s\S]*\}/,
"scrap sale outbound should label the generic item field as 废料"
);
assert.match(
inventoryViewSource,
/usesGenericSourceLotSelector[\s\S]*isScrapSaleOutbound\.value/,
"scrap sale outbound should use the stock-lot selector instead of a manual source-lot input"
);
assert.match(
inventoryViewSource,
/function buildScrapSaleSourceLotOptions\([\s\S]*source_material_sub_batch_no[\s\S]*lot_no: sourceLotNo[\s\S]*source_stock_lot_no/,
"scrap sale outbound should build selectable options from scrap lots while displaying raw-material source lot numbers"
);
assert.match(
inventoryViewSource,
/isScrapSaleOutbound\.value[\s\S]*buildScrapSaleSourceLotOptions/,
"scrap sale outbound source lot options should come from selected scrap stock"
);
assert.match(
backendInventorySource,
/_SELECTED_SOURCE_LOT_OUTBOUND_BIZ_TYPES = \{[\s\S]*"SCRAP_SALE_OUT"[\s\S]*\}/,
"backend should allow scrap sale outbound to specify selected stock lots"
);
console.log("scrap sale outbound source lot checks passed");