test: prepare unpicked dispatch drafts for browser acceptance

This commit is contained in:
2026-10-23 01:04:27 +08:00
parent 0fd523e740
commit eb82401afa
2 changed files with 10 additions and 1 deletions
@@ -19,6 +19,7 @@ export function parseFlowArguments(args) {
for(let i=0;i<args.length;i++) {
if(args[i]==='--execute')config.execute=true
else if(args[i]==='--keep-pda-for-ui')config.keepPda=true
else if(args[i]==='--stop-after-draft')config.stopAfterDraft=true
else {
const key={'--run-id':'runId','--warehouse-id':'warehouseId','--destination-warehouse-id':'destinationId','--test-image':'image','--resume-report':'resumeReport'}[args[i]]
if(!key || config[key] || !args[i+1] || args[i+1].startsWith('--'))throw Error('Unsupported or duplicate argument')
@@ -26,6 +27,7 @@ export function parseFlowArguments(args) {
}
}
if(config.execute && (!/^[A-Za-z0-9_-]{1,48}$/.test(config.runId || '') || !/^[1-9]\d*$/.test(config.warehouseId || '') || !/^[1-9]\d*$/.test(config.destinationId || '') || !config.image))throw Error('Explicit run, warehouses and synthetic image required')
if(config.stopAfterDraft && config.resumeReport)throw Error('Draft UI preparation requires a fresh attempt')
return config
}
@@ -112,6 +114,13 @@ export async function runLoadingFlow(config, env=process.env) {
report.dispatchNo=created.dispatchNo;assert(report.dispatchNo);save()
}
const path=ROOT+'/dispatches/'+report.dispatchNo, pp=PDA+'/dispatches/'+report.dispatchNo
if(config.stopAfterDraft){
const draft=await send('GET',path)
check('UI fixture remains an unpicked draft',draft.stage==='BEFORE_LOADING' && draft.reviewState==='DRAFT' && Number(draft.counts.pickedPackageCount)===0)
report.final=draft;report.executionScope='DRAFT_FIXTURE_ONLY';report.fullFlowPassed=false;report.success=true
phase('DRAFT_READY_FOR_UI')
return {success:true,executionScope:report.executionScope,dispatchNo:report.dispatchNo,report:join(directory,'report.json')}
}
if(!previous){const created=await send('GET',path);await send('POST',path+'/submit-review',{recordVersion:created.recordVersion,idempotencyKey:key('NO_SCHEDULE'),remark:'TEST missing transport schedule must block'},context.token,true)}
phase('REVIEWS_AND_REAL_PICKS')
if(previous){