Fix Canopy overview crash when rendering bot avatars
This commit is contained in:
1 parent
2b57fd62eb
commit
b24611adb7
3 files changed
+12
-5
No files matched your search
@@ -13,11 +13,13 @@ const h=(type,props,key)=>React.createElement(type,{...props,key});
|
||||
const owner={connectionId:'fixture',profile:'ops',targetProfile:'ops',mode:'remote'};
|
||||
const atom=v=>({get:()=>v});
|
||||
const actions=[], storage=new Map();
|
||||
const avatar='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
const host={state:{connectionId:atom('fixture'),profile:atom('ops'),gateway:atom('open'),
|
||||
focusedStoredSessionId:atom('1'),focusedSessionOwner:atom(owner)},
|
||||
profileRoutes:async()=>[owner],openSession:async(id,o)=>actions.push([id,o.route]),
|
||||
requestProfile:async(_route,method,p)=>{
|
||||
if(method==='profiles.list')return {profiles:[{name:'ops',display_name:'Athena'}]};
|
||||
if(method==='profiles.list')return {profiles:[{name:'ops',display_name:'Athena',has_avatar:true}]};
|
||||
if(method==='profiles.get_asset')return {found:true,data:avatar};
|
||||
if(method!=='session.list')throw Error('Unexpected RPC');
|
||||
if(p.scope==='live')return {scope:'live',sessions:[]};
|
||||
const sessions=Array.from({length:27},(_,i)=>({id:String(i+1),session_id:String(i+1),title:'Chat '+(i+1),source:'local',started_at:1760000000}));
|
||||
@@ -43,9 +45,11 @@ ReactDOM.createRoot(document.getElementById('root')).render(pane.render());
|
||||
const check=(v,label)=>{if(!v)throw Error(label);};
|
||||
const wait=async(fn)=>{for(let n=0;n<60;n++){const v=fn();if(v)return v;await new Promise(r=>setTimeout(r,20));}throw Error('UI-Merkmal nicht gefunden');};
|
||||
const button=t=>[...document.querySelectorAll('button')].find(b=>b.title===t||b.textContent===t);
|
||||
window.addEventListener('error',e=>{document.body.dataset.renderError=e.message;});
|
||||
(async()=>{
|
||||
check(pane.data.dock.pane==='sessions'&&pane.title==='Übersicht','Dock');
|
||||
const bot=await wait(()=>button('Athena'));
|
||||
await wait(()=>{const img=bot.querySelector('img');return img?.getAttribute('src')===avatar&&img.complete&&img.naturalWidth>0;});
|
||||
check(bot.getAttribute('aria-expanded')==='false','Initial collapsed');
|
||||
bot.click();
|
||||
const first=await wait(()=>button('Chat 1'));
|
||||
@@ -58,6 +62,7 @@ const button=t=>[...document.querySelectorAll('button')].find(b=>b.title===t||b.
|
||||
first.click();
|
||||
await wait(()=>actions.length);
|
||||
check(actions.length===1&&actions[0][0]==='1'&&actions[0][1]===owner,'Routed existing session');
|
||||
check(!document.body.dataset.renderError,'Render error');
|
||||
document.body.dataset.test='pass';
|
||||
})().catch(e=>{document.body.dataset.test='fail';document.body.dataset.reason=e.message;});
|
||||
`;
|
||||
|
||||
Reference in new issue
Block a user