// Design-contract checks, not a substitute for browser acceptance.
const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict');
const root=path.resolve(__dirname,'../..'),compiler=require(path.join(root,'ruoyi-ui/node_modules/vue-template-compiler'));
const read=p=>fs.readFileSync(path.join(root,'ruoyi-ui/src',p),'utf8');
const targets=['components/BusinessPageHeader/index.vue','views/businessHome/index.vue','views/project/info/index.vue','views/project/detail/index.vue','components/ProjectWorkspace/index.vue','components/ProjectWorkspace/Budget.vue','components/ProjectWorkspace/Costs.vue','components/ProjectLoans/index.vue','components/BomEditor/ProjectProducts.vue','components/SupplierPicker/index.vue','components/Production/ActionDialog.vue','components/Production/ActionHistory.vue','components/Production/BatchActions.vue','components/Production/StockOperations.vue','views/warehouse/pending/index.vue','views/warehouse/loans/index.vue','views/warehouse/suppliers/index.vue','views/warehouse/inRecord/index.vue','views/warehouse/outRecord/index.vue','views/warehouse/stock/index.vue','views/warehouse/purchase/index.vue','views/warehouse/arrival/index.vue','views/warehouse/product/index.vue','views/warehouse/area/index.vue','views/warehouse/stockCheck/index.vue','views/production/product/index.vue','views/production/bom/index.vue','views/production/tasks/index.vue','views/production/cost/index.vue','views/production/operations/index.vue','views/system/businessDictionaries/index.vue','views/system/initialization/index.vue','views/system/user/index.vue','views/system/role/index.vue','views/system/menu/index.vue','views/monitor/operlog/index.vue'];
targets.push('components/InventoryAssistant/index.vue','components/BomEditor/index.vue','components/BomEditor/ProductPicker.vue');
assert.ok(!read('layout/components/AppMain.vue').includes('name="fade-transform"'),'business pages must not animate flex/min-height while entering');
for(const p of targets){const parsed=compiler.parseComponent(read(p));assert.ok(parsed.template,p+' template missing');const result=compiler.compile(parsed.template.content);assert.equal(result.errors.length,0,p+': '+result.errors.join(';'));}
const workspace=read('components/ProjectWorkspace/index.vue');
for(const label of ['总览','分类预算','产品与BOM','采购','库存','借用与归还','生产','成本与损耗'])assert.ok(workspace.includes(`label="${label}"`),'missing tab '+label);
for(const component of ['project-budget','project-products','purchase-page','stock-page','project-loans','production-tasks','project-costs'])assert.ok(workspace.includes('<'+component),'missing embedded business '+component);
assert.ok(!workspace.includes('查看 / 维护项目产品与BOM'));
const purchase=read('views/warehouse/purchase/index.vue');assert.ok(!purchase.includes('@row-click="openDetail"'));assert.ok(!purchase.includes('
'),'purchase maintenance actions must be hidden in arrival mode');
const pageHeaderTargets=['views/businessHome/index.vue','views/project/info/index.vue','components/ProjectWorkspace/index.vue','views/warehouse/purchase/index.vue','views/warehouse/inRecord/index.vue','views/warehouse/outRecord/index.vue','views/warehouse/stock/index.vue','views/warehouse/loans/index.vue','views/warehouse/stockCheck/index.vue','views/production/tasks/index.vue','views/warehouse/product/index.vue','views/production/product/index.vue','views/production/bom/index.vue','views/warehouse/suppliers/index.vue','views/warehouse/area/index.vue','views/system/businessDictionaries/index.vue','views/system/initialization/index.vue','views/system/user/index.vue','views/system/role/index.vue','views/system/menu/index.vue','views/monitor/operlog/index.vue'];
for(const page of pageHeaderTargets){if(page==='views/warehouse/purchase/index.vue'){assert.ok(read(page).includes('
删除未使用<'));
assert.ok(!purchase.includes('transform: translateY'),'floating dashboard-card effect returned to procurement pages');
const pending=read('views/warehouse/inRecord/index.vue');assert.ok(pending.includes('pendingOnly:Boolean'));assert.ok(pending.includes('if(this.pendingOnly)this.queryParams.inStatus=0'));
assert.ok(pending.includes(':selectable="canSelectPendingRecord"'),'inbound selection must only include pending records');
const stock=read('views/warehouse/stock/index.vue');for(const marker of ['finishedProduct','canSelectStock','SCRAP_STOCK','SCRAP_FINISHED','DELIVERY'])assert.ok(stock.includes(marker),'stock business control missing '+marker);
const stockOperations=read('components/Production/StockOperations.vue');for(const marker of ['operationOptions','targetAreas','只有产品档案中的成品库存','请填写交付接收方'])assert.ok(stockOperations.includes(marker),'stock operation guard missing '+marker);
const actionDialog=read('components/Production/ActionDialog.vue');assert.ok(actionDialog.includes('stockMatchesKind'));assert.ok(actionDialog.includes("task.status === 'SETTLED'"));
const productionTasks=read('views/production/tasks/index.vue');for(const marker of ['canSelectTask','needOutstanding','hasIssuableNeeds',"detail.status==='OPEN'"])assert.ok(productionTasks.includes(marker),'production task state control missing '+marker);
for(const marker of ['继续生产','reopenTask','await this.$confirm','settleTask(id,version)','production-task-dialog','command="SCRAP_ASSEMBLY"'])assert.ok(productionTasks.includes(marker),'production usability control missing '+marker);
assert.ok(read('components/BomEditor/ProjectProducts.vue').includes('0'),'return action must require an outstanding quantity');
const projectLoans=read('components/ProjectLoans/index.vue');assert.ok(projectLoans.includes(':selectable="canSelectLoan"'));assert.ok(projectLoans.includes('canRevokeLoan'));
for(const marker of ['canBatchArrivalSelection','canBulkEditSelection','canLockSelection','canDeleteSelection','canEditPrice','receivedQuantity'])assert.ok(purchase.includes(marker),'purchase business control missing '+marker);
const home=read('views/businessHome/index.vue');assert.ok(home.includes('