ForgeFlow-ERP/frontend/scripts/test-production-scrap-entry-hidden.mjs
2026-06-12 16:00:56 +08:00

48 lines
2.0 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
const root = process.cwd();
function readSource(relativePath) {
return readFileSync(path.join(root, relativePath), "utf8");
}
const app = readSource("src/App.vue");
const router = readSource("src/router/index.js");
const workspace = readSource("src/views/ProductionWorkspaceView.vue");
const operationReports = readSource("src/views/OperationReportView.vue");
const inventoryLedger = readSource("src/views/InventoryLedgerView.vue");
assert.doesNotMatch(
app,
/key:\s*"scrap-rework"[\s\S]*?label:\s*"生产报废"/,
"production side menu should not expose the production scrap entry"
);
assert.doesNotMatch(
app,
/routeNames:\s*\[[\s\S]*?"scrap-rework"[\s\S]*?\]/,
"production module route activation should not include scrap-rework"
);
assert.doesNotMatch(
app,
/permissionsAny:\s*\[[\s\S]*?"MENU_SCRAP_REWORK"[\s\S]*?\]/,
"production module permissions should not depend on the hidden scrap entry"
);
assert.doesNotMatch(
router,
/const productionPermissionOrder = \[[\s\S]*?routeName:\s*"scrap-rework"/,
"production permission order should not choose the production scrap route"
);
assert.doesNotMatch(workspace, /ScrapReworkView/, "production workspace should not import the scrap page");
assert.doesNotMatch(workspace, /label:\s*"生产报废"/, "production workspace should not show a production scrap card");
assert.match(workspace, /title="生产台账与小程序报工"/, "production workspace title should describe the remaining production entries");
assert.match(workspace, /生产台账/, "production workspace should keep the production ledger wording");
assert.match(operationReports, /报废数量/, "operation report page should still keep reported scrap quantity");
assert.match(inventoryLedger, /生产废料入库/, "scrap warehouse production scrap inbound should remain available");
console.log("production scrap entry hidden checks passed");