feat: unify BPM health and guard session recovery with state machines

This commit is contained in:
阿白叔 committed 2026-10-24 14:49:15 +08:00
1 parent 97e06328c3
commit 42d19c707d
23 files changed
+681 -90

No files matched your search

+11
View File
@@ -9,6 +9,17 @@ async function setup(t,options={}){
const login=async(username)=>(await call('/api/login',{username,password:'Test-password-123'})).headers['set-cookie'][0].split(';')[0];const cookie=await login('admin');const connection=(await call('/api/connections',{name:'BPM',owner:'alice'},cookie)).json();const route='/api/connections/'+connection.id;
return {call,login,cookie,workspace,store,manager,connection,route,setResult:value=>{next=value;},counts:()=>({disabled,released,suspended}),jpg};
}
test('connection operation replies share workspace account and sync conclusions immediately',async t=>{
const s=await setup(t),checkedAt=new Date().toISOString();
s.setResult({status:'connected',identity:'fixture',checkedAt,checks:{portal:{ok:true,message:'已验证'}}});
const checked=await s.call(s.route+'/check',{},s.cookie);assert.equal(checked.status,200);
assert.equal(checked.json().connectionState.account.status,'healthy');
const workspace=(await s.call('/api/workspace',undefined,s.cookie)).json();
assert.deepEqual(checked.json().connectionState,workspace.connections[0].connectionState);
const paused=await s.call(s.route+'/disable',{},s.cookie);
assert.equal(paused.json().connectionState.account.status,'paused');assert.equal(paused.json().connectionState.sync.status,'paused');
});
test('deleting a disabled connection enforces admin, cleans custody first, and preserves the entry on cleanup failure',async t=>{
const s=await setup(t);const endpoint=s.route+'/delete';
assert.equal((await s.call(endpoint,{},s.cookie)).status,409);