修复匹配详情中“用户自填未经核验”等来源说明,清理未参与项的橙色注意提示,修正贷款统计口径文案;补充公积金完整可选路径提取逻辑,确保明确无额外时长要求的公积金分支可正确识别并通过。
41 lines
4.7 KiB
JavaScript
41 lines
4.7 KiB
JavaScript
// Execute the analysis page's actual lifecycle with synthetic status responses; no network/model access.
|
|
const fs=require('node:fs'),path=require('node:path'),vm=require('node:vm'),assert=require('node:assert/strict');
|
|
const ts=require('D:/Develop/HBuilderX/plugins/uniapp-uts-v1/node_modules/@dcloudio/uni-uts-v1/lib/typescript/lib/typescript.js');
|
|
const repo=path.resolve(__dirname,'..');
|
|
const compile=source=>ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2020}}).outputText;
|
|
const routeExports={};vm.runInNewContext(compile(fs.readFileSync(path.join(repo,'services/report-route.uts'),'utf8')),{exports:routeExports});
|
|
const script=fs.readFileSync(path.join(repo,'packages/finance/analyzing/analyzing.uvue'),'utf8').match(/<script setup lang="uts">([\s\S]*?)<\/script>/)[1];
|
|
function status(overrides={}){return {id:'42',revisionId:'9',publishedRevisionId:'9',status:'succeeded',statusLabel:'分析完成',message:'',hasReport:true,stage:'completed',canRetry:false,taskId:'task9',...overrides};}
|
|
function page(reply){
|
|
let token='synthetic-owner',response=reply,onLoad,onShow,onHide,onUnload;const navigations=[],timers=[];
|
|
const session=()=>token==null?null:{token,getString:key=>key==='token'?token:''};
|
|
const context={exports:{},Error,Date,Math,Promise,ref:value=>({value}),
|
|
onLoad:fn=>{onLoad=fn},onShow:fn=>{onShow=fn},onHide:fn=>{onHide=fn},onUnload:fn=>{onUnload=fn},
|
|
setTimeout:fn=>{timers.push(fn);return timers.length},clearTimeout:()=>{},setInterval:()=>1,clearInterval:()=>{},
|
|
uni:{redirectTo:({url})=>{navigations.push({kind:'redirect',url})},navigateTo:({url})=>{navigations.push({kind:'navigate',url})}},
|
|
require:module=>module.endsWith('layout.uts')?{usePageLayout:()=>({})}:module.endsWith('api.uts')?{getSession:session}:module.endsWith('records.uts')?{fetchAssessmentStatus:async()=>typeof response==='function'?response():response}:module.endsWith('report-route.uts')?routeExports:(()=>{throw Error('Unexpected dependency '+module)})()};
|
|
vm.runInNewContext(compile(script+'\nexports.refreshStatus=refreshStatus; exports.report=report; exports.statusMessage=()=>message.value;'),context);
|
|
onLoad({assessmentId:'42'});
|
|
return {navigations,timers,show:()=>onShow(),hide:()=>onHide(),setReply:r=>{response=r},setToken:t=>{token=t},refresh:()=>context.exports.refreshStatus(),manualReport:()=>context.exports.report(),message:()=>context.exports.statusMessage()};
|
|
}
|
|
const flush=async()=>{await Promise.resolve();await Promise.resolve();await Promise.resolve()};
|
|
let checks=0;const check=(ok,label)=>{assert.ok(ok,label);checks++};
|
|
(async()=>{
|
|
let p=page(status());p.show();await flush();
|
|
check(p.navigations.length===1,'successful analysis automatically opens its result');
|
|
assert.deepEqual(p.navigations[0],{kind:'redirect',url:'/packages/finance/report/report?assessmentId=42&tab=matches&revisionId=9'});checks++;
|
|
check(p.timers.length===0,'successful result does not keep polling');
|
|
p=page(status({status:'processing',stage:'queued',revisionId:'10',publishedRevisionId:'9'}));p.show();await flush();
|
|
check(p.navigations.length===0&&p.timers.length===1,'processing revision never opens the older published report');
|
|
p.setReply(status({revisionId:'10',publishedRevisionId:'10'}));p.timers[0]();await flush();
|
|
check(p.navigations.length===1&&p.navigations[0].url.endsWith('tab=matches&revisionId=10'),'poll completion opens the newly published revision');
|
|
p=page(status({status:'failed',canRetry:true}));p.show();await flush();check(p.navigations.length===0,'failed assessment stays on recovery page');
|
|
check(p.message().includes('分析未完成')&&!p.message().includes('可查看本次报告'),'failed analysis without server message does not announce completed report');
|
|
p=page(status({hasReport:false,publishedRevisionId:''}));p.show();await flush();check(p.navigations.length===0,'missing report never navigates to an unfrozen result');
|
|
p=page(status({publishedRevisionId:'8'}));p.show();await flush();check(p.navigations.length===0,'inconsistent published revision is not opened as the new result');
|
|
let resolve;const pending=new Promise(r=>{resolve=r});p=page(()=>pending);p.show();p.hide();resolve(status());await flush();check(p.navigations.length===0,'late response after leaving cannot navigate');
|
|
let switched;const delayed=new Promise(r=>{switched=r});p=page(()=>delayed);p.show();p.setToken('other-account');switched(status());await flush();check(p.navigations.length===0,'account switch rejects former account result');
|
|
p=page(status());p.setToken(null);p.show();await flush();check(p.navigations[0].url==='/packages/account/login/login','expired session requires login');
|
|
console.log('PASS: '+checks+' analysis result route checks; no network/model access');
|
|
})().catch(e=>{console.error(e);process.exitCode=1});
|