Elffuss BraidHub

utopia-ia/elffuss-code public

2df00d521f0c · 3.0 KiBRawPermalink
1// Ocultar el explorador (icono de ficheros de la barra de actividad) no puede
2// llevarse el editor por delante.
3//
4// Antes, con el árbol oculto (display:none), el editor y el chat se corrían una
5// columna de la rejilla: el editor caía en la de 0 px y desaparecía, el chat
6// ocupaba su sitio y la columna del chat se quedaba vacía. Con «chat a toda la
7// ventana» a la vez, desaparecía también el chat.
8//
9// BASE=http://127.0.0.1:8898 node tests/sidebar-toggle.mjs
10import { chromium } from 'playwright';
11const BASE = process.env.BASE || 'http://localhost:8799';
12let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
13
14const b = await chromium.launch();
15const ctx = await b.newContext({ locale: 'es-ES', viewport: { width: 1280, height: 800 } });
16await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); localStorage.removeItem('elffusscode.chatfull'); } catch {} });
17await ctx.route(/soundcloud|huggingface|hf\.co|api\.github|raw\.githubusercontent/, r => r.abort());
18const p = await ctx.newPage();
19const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
20await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
21await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 30000 });
22const caja = sel => p.evaluate(sel => { const r = document.querySelector(sel).getBoundingClientRect(); return { x: Math.round(r.x), w: Math.round(r.width) }; }, sel);
23
24const antes = { ed: await caja('#editor-wrap'), chat: await caja('#chat') };
25await p.click('#act-files');
26await p.waitForTimeout(200);
27const oculto = { ed: await caja('#editor-wrap'), chat: await caja('#chat'), arbol: await p.isVisible('#sidebar') };
28ok('ocultar el árbol lo oculta', !oculto.arbol);
29ok('…y el editor sigue ahí, ocupando el hueco del árbol', oculto.ed.x === 46 && oculto.ed.w > antes.ed.w, JSON.stringify(oculto));
30ok('…y el chat se queda en su columna, pegado a la derecha', oculto.chat.x + oculto.chat.w === 1280 && oculto.chat.w === antes.chat.w, JSON.stringify(oculto.chat));
31ok('el icono de ficheros dice que el árbol está oculto', await p.evaluate(() => !document.getElementById('act-files').classList.contains('on')));
32
33await p.click('#btn-ancho');
34await p.waitForTimeout(200);
35const ancho = await caja('#chat');
36ok('con el árbol oculto, «chat a toda la ventana» sigue enseñando el chat', ancho.w > 1000, JSON.stringify(ancho));
37await p.click('#btn-ancho');
38await p.click('#act-files');
39await p.waitForTimeout(200);
40const vuelta = { ed: await caja('#editor-wrap'), chat: await caja('#chat') };
41ok('volver a enseñar el árbol lo deja como estaba', JSON.stringify(vuelta) === JSON.stringify(antes), JSON.stringify(vuelta));
42ok('sin errores de página', !errs.length, errs.join(' | '));
43await b.close();
44console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ explorador: ocultar y enseñar sin romper la rejilla');
45process.exit(fails ? 1 : 0);