'use strict'; const test=require('node:test'),assert=require('node:assert/strict'); const {captureDetail}=require('../src/bpm-order-detail.cjs'); const {loadPlaywright,browserOptions}=require('../src/runtime.cjs'); const origin='https://bpm.skyworthdigital.com'; async function capture(path,processName,listProcessVersion){ const url=origin+path+'?tid=100&pid=200';let reads=0; const request={get:async target=>{assert.equal(target,new URL(url).href);reads++;return {status:()=>200,body:async()=>Buffer.from('
')};},post:async()=>({status:()=>200,body:async()=>Buffer.from(JSON.stringify({success:true,Tables:[{TableName:'T',FormTable:true,Rows:[{No:'000123'}]}]}))}),dispose:async()=>{}}; const result=await captureDetail({storageState:{cookies:[],origins:[]},detailUrl:url,processName,nodeName:'fixture-node',listProcessVersion,readonlyData:true,fieldsOnly:true,requestFactory:async()=>request,browserFactory:()=>loadPlaywright().chromium.launch(browserOptions())}); assert.equal(reads,1);return result; } test('verified domestic form alias keeps the authoritative list process and actual form name separate',async()=>{ const result=await capture('/YZSoft/Forms/XForm/国内订单评审/国内订单评审V18.aspx','国内运营订单评审','3.9'); assert.equal(result.detail.processName,'国内运营订单评审');assert.equal(result.detail.formName,'国内订单评审');assert.equal(result.detail.formVersion,'V18');assert.equal(result.detail.processVersion,'V18');assert.equal(result.detail.listProcessVersion,'3.9');assert.equal(result.detail.formMatchSource,'verified-form-contract'); }); test('a verified unversioned form uses an explicit path and list-version adapter key without inventing a V number',async()=>{ const path='/YZSoft/Forms/XForm/2012订单评审系列/加工订单评审/加工订单通知书.aspx',result=await capture(path,'加工订单评审','1.0'); assert.equal(result.detail.formVersion,null);assert.equal(result.detail.formName,'加工订单通知书');assert.equal(result.detail.processName,'加工订单评审');assert.equal(result.detail.processVersion,'list:1.0|form:'+path);assert.equal(result.detail.fields['T.No'],'000123'); }); test('an alias never bypasses a mismatching process, list version or full form path',async()=>{ const path='/YZSoft/Forms/XForm/国内订单评审/国内订单评审V18.aspx'; await assert.rejects(()=>capture(path,'另一流程','3.9'),/流程|表单/); await assert.rejects(()=>capture(path,'国内运营订单评审','unverified-version'),/版本|核验/); await assert.rejects(()=>capture(path,'国内运营订单评审',null),/版本|核验/); await assert.rejects(()=>capture('/YZSoft/Forms/XForm/other/国内订单评审V18.aspx','国内运营订单评审','3.9'),/流程|表单/); await assert.rejects(()=>capture('/YZSoft/Forms/XForm/unknown.aspx','unknown','1.0'),/核验|版本|表单/); });