import test from 'node:test';import assert from 'node:assert/strict';import {readFile} from 'node:fs/promises'; import {modules,routeComponents,validDate,recordDisplay} from '../src/core/modules.ts'; test('native module fields agree with backend DTO names, not guessed desktop labels',async()=>{ const purchase=modules.find(m=>m.key==='purchase'),out=modules.find(m=>m.key==='out'); assert.ok(purchase.fields.some(([key])=>key==='purchaseBatchNo'));assert.ok(out.fields.some(([key])=>key==='usageProjectName')); for(const [module,file] of [[purchase,'PurchaseRequest'],[out,'OutRecord']]){ const source=await readFile(new URL(`../../ruoyi-system/src/main/java/com/ruoyi/warehouse/domain/${file}.java`,import.meta.url),'utf8'); for(const [key] of module.fields)assert.ok(source.includes(`get${key[0].toUpperCase()+key.slice(1)}(`),`Missing backend getter ${file}.${key}`); } }); test('page-level production access comes from authorized server routes, not a made-up permission',()=>{ const production=modules.find(m=>m.key==='production');assert.ok(production.pages.includes('production/tasks/index')); assert.ok(!production.permissions.flat().includes('production:entry')); assert.deepEqual(routeComponents([{component:'Layout',children:[{component:'production/tasks/index'}]}]),['Layout','production/tasks/index']); assert.equal(recordDisplay(production,'status','SETTLED'),'已结算'); }); test('date validation rejects silent calendar rollover and accepts leap dates',()=>{ assert.equal(validDate('2026-02-31'),false);assert.equal(validDate('2026-13-01'),false);assert.equal(validDate('2026-10-17'),true);assert.equal(validDate('2024-02-29'),true);assert.equal(validDate('2026-02-29'),false); });