feat(web): close settings navigation and page lifecycle

This commit is contained in:
abaishu0730 committed 2026-10-19 12:41:51 +08:00
1 parent 539b33cd42
commit 37b4a156c9
19 files changed
+182 -101

No files matched your search

+2 -2
View File
@@ -258,7 +258,7 @@ test('narrow screens keep the frame inside the page and native typing forwards t
test('refresh and logout release BPM control before rendering or dropping authentication',async()=>{
const vm=require('node:vm'),events=[],elements=new Map();
const element=id=>{if(!elements.has(id))elements.set(id,{innerHTML:'',textContent:'',classList:{remove(){}},querySelector(){return {disabled:false};}});return elements.get(id);};
const context=vm.createContext({Intl,setTimeout,clearInterval,location:{hash:'#overview'},document:{querySelector:element,querySelectorAll:()=>[]},window:{addEventListener(){},BpmLogin:{dispose:async()=>events.push('release')},WorkspaceViews:{overview:async()=>events.push('render')}}});
const context=vm.createContext({Intl,setTimeout,clearInterval,location:{hash:'#overview'},history:{replaceState(){}},document:{querySelector:element,querySelectorAll:()=>[],addEventListener(){}},window:{addEventListener(){},PageLifecycle:{guard:fn=>fn(),dispose:async()=>{},attach(){},bind(){}},AppNavigation:{primary:[],resolve:id=>id,sectionFor:()=>null,renderTabs(){}},BpmLogin:{dispose:async()=>events.push('release')},WorkspaceViews:{overview:async()=>events.push('render')}}});
const source=fs.readFileSync(path.join(__dirname,'../../web/app.js'),'utf8').replace(/boot\(\)\.catch[\s\S]*$/,'');
vm.runInContext(source,context);
await vm.runInContext("currentUser={username:'alice',role:'admin'};renderView()",context);
@@ -268,7 +268,7 @@ test('refresh and logout release BPM control before rendering or dropping authen
});
test('an expired login request rejects without waiting on its own remote cleanup',async()=>{
const vm=require('node:vm'),events=[];
const context=vm.createContext({Intl,setTimeout,fetch:async()=>({status:401,ok:false,json:async()=>({error:'请重新登录。'})}),document:{querySelector:()=>({})},window:{addEventListener(){},BpmLogin:{dispose:()=>new Promise(()=>{})}},events});
const context=vm.createContext({Intl,setTimeout,clearTimeout,AbortController,AbortSignal,fetch:async()=>({status:401,ok:false,json:async()=>({error:'请重新登录。'})}),document:{querySelector:()=>({}),addEventListener(){}},window:{addEventListener(){},BpmLogin:{dispose:()=>new Promise(()=>{})}},events});
const source=fs.readFileSync(path.join(__dirname,'../../web/app.js'),'utf8').replace(/boot\(\)\.catch[\s\S]*$/,'');vm.runInContext(source,context);
const pending=vm.runInContext("currentUser={username:'alice',role:'operator'};boot=async()=>events.push('login');api('/connections/one/login/open',{}).then(()=> 'resolved',()=> 'rejected')",context);
assert.equal(await Promise.race([pending,new Promise(resolve=>setTimeout(()=>resolve('pending'),100))]),'rejected');assert.deepEqual(events,['login']);