Elffuss BraidHub

utopia-ia/elffuss-code public

99a5df28cf0f · 3.2 KiBRawPermalink
1// Bug A: al cerrar la última pestaña → estado vacío (no Monaco en blanco).
2// Bug B: abrir/cerrar/alternar vistas (grafo/ciudad) → siempre cargan bien.
3import { chromium } from 'playwright';
4const OUT=(process.env.SCRATCH || '/tmp/elffuss-test');
5const BASE = process.env.BASE || 'http://localhost:8799';
6let fails=0; const ok=(n,c,e='')=>{console.log((c?'✅':'❌')+' '+n+(e?' — '+e:''));if(!c)fails++};
7const b=await chromium.launch({args:['--enable-unsafe-webgpu','--use-angle=metal']});
8const ctx=await b.newContext(); await ctx.addInitScript(()=>{try{localStorage.setItem('elffusscode.model','rules')}catch{}});
9const p=await ctx.newPage({viewport:{width:1500,height:900}});
10p.on('pageerror',e=>{if(!/allow-same-origin/.test(e.message))console.log(' pageerror:',e.message.slice(0,120))});
11await p.goto(BASE+'/',{waitUntil:'domcontentloaded'});
12await p.evaluate(async()=>{const o=await navigator.storage.getDirectory();const w=async(path,txt)=>{const pr=path.split('/');const nm=pr.pop();let d=o;for(const x of pr)d=await d.getDirectoryHandle(x,{create:true});const f=await d.getFileHandle(nm,{create:true});const s=await f.createWritable();await s.write(txt);await s.close()};
13 await w('README.md','# demo'); await w('src/a.js',"import {b} from './b.js';\nexport const a=b;"); await w('src/b.js',"export const b=1;");});
14await p.goto(BASE+'/?test-opfs',{waitUntil:'domcontentloaded'}); await p.waitForTimeout(2500);
15
16// ── Bug A ──
17await p.locator('#tree').getByText('README.md').first().click(); await p.waitForTimeout(700);
18ok('al abrir un fichero, sin estado vacío', await p.evaluate(()=>{const e=document.getElementById('editor-empty');return !e||getComputedStyle(e).display==='none';}));
19await p.locator('#tabs-bar .tab b').first().click(); await p.waitForTimeout(500); // cerrar la pestaña
20ok('al cerrar la última pestaña → estado vacío visible', await p.evaluate(()=>{const e=document.getElementById('editor-empty');return !!e && getComputedStyle(e).display!=='none';}));
21
22// ── Bug B ── abrir/cerrar/alternar vistas varias veces
23const openArch=async()=>{ await p.click('#act-arch'); await p.waitForTimeout(3500); return p.evaluate(()=>{const g=document.getElementById('arch-graph');return !!g && !!g.querySelector('canvas') && +g.dataset.nodes>0;}); };
24const openCity=async()=>{ await p.click('#act-city'); await p.waitForTimeout(3500); return p.evaluate(()=>{const c=document.getElementById('city-canvas');const gl=c&&(c.getContext('webgl2')||c.getContext('webgl'));return !!gl && !gl.isContextLost() && c.width>50; }); };
25ok('grafo carga (1ª vez)', await openArch());
26await p.click('#view-close'); await p.waitForTimeout(400);
27ok('ciudad carga tras cerrar el grafo', await openCity());
28await p.click('#view-close'); await p.waitForTimeout(400);
29ok('grafo RE-carga (reapertura)', await openArch());
30// alternar directo grafo→ciudad sin cerrar
31ok('ciudad carga alternando directo desde el grafo', await openCity());
32ok('grafo carga alternando directo desde la ciudad', await openArch());
33await p.screenshot({path:OUT+'/bugs.png'});
34console.log(fails?`\n❌ ${fails} FALLO(S)`:'\n✅ BUGS (estado vacío + recarga de vistas) OK');
35await b.close(); process.exit(fails?1:0);