Elffuss BraidHub

utopia-ia/elffuss-code public

main · 3.8 KiBRawPermalink
1// Móvil: el cajón ☰ con el árbol y las herramientas.
2//
3// En un teléfono la barra de actividad, el árbol y la barra de menús están
4// ocultos, así que en la vista Editor no había forma de abrir un fichero (solo
5// enlaces del chat o @) y la Mente, el terminal, las vistas 3D y las skills
6// eran inalcanzables. Ahora ☰ abre un cajón con todo eso.
7//
8// BASE=http://127.0.0.1:8898 node tests/mobile-drawer.mjs
9import { chromium } from 'playwright';
10const BASE = process.env.BASE || 'http://localhost:8799';
11let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
12
13const b = await chromium.launch();
14const ctx = await b.newContext({ locale: 'es-ES', viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
15await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
16await ctx.route(/soundcloud/, r => r.abort());
17const p = await ctx.newPage();
18const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
19
20await p.goto(BASE + '/manifest.json');
21await p.evaluate(async () => {
22 const root = await navigator.storage.getDirectory();
23 const w = await (await root.getFileHandle('README.md', { create: true })).createWritable(); await w.write('# Hola\n'); await w.close();
24});
25await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
26await p.waitForFunction(() => window.monaco && document.querySelector('#tree [data-path]'), null, { timeout: 30000 });
27const visible = sel => p.evaluate(sel => { const e = document.querySelector(sel); if (!e) return false; const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(e).display !== 'none'; }, sel);
28
29ok('en el móvil, el árbol y la barra de actividad empiezan ocultos', !(await visible('#sidebar')) && !(await visible('#activity')));
30ok('…y hay un botón ☰', await visible('#btn-drawer'));
31await p.tap('#btn-drawer');
32await p.waitForTimeout(200);
33ok('☰ abre el cajón con el árbol y las herramientas', await visible('#sidebar') && await visible('#activity') && await visible('#act-term') && await p.evaluate(() => document.getElementById('btn-drawer').getAttribute('aria-expanded') === 'true'));
34await p.tap('#tree .file[data-path="README.md"]');
35await p.waitForTimeout(400);
36const trasAbrir = await p.evaluate(() => ({ editor: document.body.classList.contains('show-editor'), cajon: document.body.classList.contains('drawer-open'), activa: document.querySelector('#tabs-bar .tab.active')?.dataset.path }));
37ok('un fichero del cajón se abre en la vista Editor y el cajón se cierra', trasAbrir.editor && !trasAbrir.cajon && trasAbrir.activa === 'README.md', JSON.stringify(trasAbrir));
38await p.tap('#btn-drawer');
39await p.waitForTimeout(150);
40await p.tap('#act-term');
41await p.waitForTimeout(400);
42ok('desde el cajón se llega al terminal', await visible('#terminal-panel') && !(await p.evaluate(() => document.body.classList.contains('drawer-open'))));
43await p.tap('#btn-drawer');
44await p.waitForTimeout(150);
45await p.keyboard.press('Escape');
46await p.waitForTimeout(150);
47ok('Escape cierra el cajón y devuelve el foco a ☰', await p.evaluate(() => !document.body.classList.contains('drawer-open')));
48await p.tap('#btn-drawer');
49await p.waitForTimeout(150);
50await p.tap('#act-mind');
51await p.waitForSelector('#mind-overlay', { timeout: 45000 }).catch(() => {});
52ok('desde el cajón se llega a la Mente', await p.evaluate(() => !!document.getElementById('mind-overlay') && getComputedStyle(document.getElementById('mind-overlay')).display !== 'none'));
53
54console.log('\n errores JS:', errs[0] || 'ninguno');
55ok('sin errores de página', errs.length === 0, errs.join(' | '));
56console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ MÓVIL: EL CAJÓN LLEVA A TODO');
57await b.close();
58process.exit(fails ? 1 : 0);