Elffuss BraidHub

utopia-ia/elffuss-code public

main · 2.4 KiBRawPermalink
1// La consola no puede quedar tapada por las capas del editor. El aviso de «sin
2// ficheros» y la vista previa de Markdown se estiraban hasta la barra de estado
3// y, con la consola abierta, el clic en la consola caía en el aviso.
4import { chromium } from 'playwright';
5const BASE = process.env.BASE || 'http://localhost:8799';
6let fails = 0;
7const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
8
9const b = await chromium.launch();
10const ctx = await b.newContext({ viewport: { width: 1280, height: 760 } });
11await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
12const p = await ctx.newPage();
13p.on('pageerror', e => { console.log('❌ pageerror: ' + e.message); fails++; });
14await p.goto(BASE + '/?test-opfs');
15await p.waitForFunction(() => !!document.querySelector('#editor .monaco-editor'), null, { timeout: 30000 });
16await p.waitForTimeout(500);
17
18const aviso = () => p.evaluate(() => {
19 const e = document.getElementById('editor-empty'), w = document.getElementById('editor-wrap');
20 return { visible: getComputedStyle(e).display !== 'none', fondo: Math.round(w.getBoundingClientRect().bottom - e.getBoundingClientRect().bottom) };
21});
22const a0 = await aviso();
23ok('⊕ control: el aviso vacío está a la vista (es la capa que tapaba)', a0.visible);
24
25await p.click('#act-term');
26await p.waitForTimeout(800);
27const r = await p.evaluate(() => {
28 const t = document.getElementById('terminal-panel').getBoundingClientRect();
29 const quien = (x, y) => { let el = document.elementFromPoint(x, y); while (el) { if (el.id === 'terminal-panel') return true; el = el.parentElement; } return false; };
30 return {
31 alto: Math.round(t.height),
32 centro: quien(t.left + t.width / 2, t.top + t.height / 2),
33 arriba: quien(t.left + t.width / 2, t.top + 12),
34 };
35});
36ok('⊕ control: la consola se ha abierto con altura', r.alto > 50, `${r.alto}px`);
37ok('el centro de la consola es la consola, no una capa encima', r.centro);
38ok('su cabecera también', r.arriba);
39
40await p.click('#term-close');
41await p.waitForTimeout(400);
42const a1 = await aviso();
43ok('al cerrarla, el aviso vuelve a llegar hasta la barra de estado', a1.visible && a1.fondo <= 23, `deja ${a1.fondo}px abajo`);
44
45await b.close();
46console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\nTodo en verde');
47process.exit(fails ? 1 : 0);