| 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. |
| 4 | import { chromium } from 'playwright'; |
| 5 | const BASE = process.env.BASE || 'http://localhost:8799'; |
| 6 | let fails = 0; |
| 7 | const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; |
| 8 | |
| 9 | const b = await chromium.launch(); |
| 10 | const ctx = await b.newContext({ viewport: { width: 1280, height: 760 } }); |
| 11 | await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); |
| 12 | const p = await ctx.newPage(); |
| 13 | p.on('pageerror', e => { console.log('❌ pageerror: ' + e.message); fails++; }); |
| 14 | await p.goto(BASE + '/?test-opfs'); |
| 15 | await p.waitForFunction(() => !!document.querySelector('#editor .monaco-editor'), null, { timeout: 30000 }); |
| 16 | await p.waitForTimeout(500); |
| 17 | |
| 18 | const 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 | }); |
| 22 | const a0 = await aviso(); |
| 23 | ok('⊕ control: el aviso vacío está a la vista (es la capa que tapaba)', a0.visible); |
| 24 | |
| 25 | await p.click('#act-term'); |
| 26 | await p.waitForTimeout(800); |
| 27 | const 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 | }); |
| 36 | ok('⊕ control: la consola se ha abierto con altura', r.alto > 50, `${r.alto}px`); |
| 37 | ok('el centro de la consola es la consola, no una capa encima', r.centro); |
| 38 | ok('su cabecera también', r.arriba); |
| 39 | |
| 40 | await p.click('#term-close'); |
| 41 | await p.waitForTimeout(400); |
| 42 | const a1 = await aviso(); |
| 43 | ok('al cerrarla, el aviso vuelve a llegar hasta la barra de estado', a1.visible && a1.fondo <= 23, `deja ${a1.fondo}px abajo`); |
| 44 | |
| 45 | await b.close(); |
| 46 | console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\nTodo en verde'); |
| 47 | process.exit(fails ? 1 : 0); |