41 lines
4.2 KiB
JavaScript
41 lines
4.2 KiB
JavaScript
'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('<form><input xdatabind="T.No"></form>')};},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'),/流程|表单/);
|
|
const candidate=await capture(path,'国内运营订单评审','4.0');assert.equal(candidate.detail.formMatchSource,'verified-form-path-new-list-version');assert.equal(candidate.detail.listProcessVersion,'4.0');assert.equal(candidate.detail.formVersion,'V18');
|
|
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'),/核验|版本|表单/);
|
|
});
|
|
|
|
test('new list version only permits read-only capture on a verified versioned form path without inheriting old field omissions',async()=>{
|
|
const {resolveFormIdentity}=require('../src/bpm-form-contracts.cjs'),formPath='/YZSoft/Forms/XForm/2012订单评审系列/海外运营订单评审/海外运营订单更改评审V7.aspx';
|
|
const identity={url:new URL(origin+formPath),processName:'海外运营订单更改评审',processVersion:'V7'};
|
|
const result=resolveFormIdentity(identity,{processName:'海外运营订单更改评审',listProcessVersion:'2.0'});
|
|
assert.equal(result.formMatchSource,'verified-form-path-new-list-version');assert.deepEqual(result.contractListVersions,['1.9']);assert.equal(result.ignoredDisplayFields,undefined);
|
|
const unversioned='/YZSoft/Forms/XForm/2012订单评审系列/加工订单评审/加工订单通知书.aspx';
|
|
assert.throws(()=>resolveFormIdentity({url:new URL(origin+unversioned),processName:'加工订单通知书',processVersion:null},{processName:'加工订单评审',listProcessVersion:'1.1'}),/版本|契约/);
|
|
});
|