Elffuss BraidHub

utopia-ia/elffuss-code public

Tests: catch up with UI changes (locale, the Modes menu, the Stop button, reworded errors, the Mind v3)

Each test is fixed to the behaviour the cited commit introduced on purpose;
the product is unchanged.

- contrast.mjs opened '/', where only the landing shows since 77fb41b hid the
  IDE behind it, and ran 0 checks: it opens ?test-opfs and waits for the IDE.
- filelinks2.mjs and streampreview.mjs pin es-ES: since 7d5e790 the UI follows
  the browser's language, and they assert Spanish text.
- goalmode.mjs opens the Modes menu before toggling Goal (43f95b7 moved it
  there) and pins es-ES (plan states are localized since e4415eb).
- autoedit_settings.mjs pins es-ES and opens the Modes menu for Auto (same
  two commits).
- sendfeedback.mjs expected the busy button to be disabled; since 2421c1b it
  turns into Stop and stays clickable.
- codeedit.mjs expected "mas de una vez"; since b418762 the ambiguity error
  says where the text appears ("aparece N veces en <file> (lineas ...)").
- mind.mjs counted the floating consoles of the Mind v2, gone since 603262e;
  it counts the stars each profile leaves now (in the same step, since stars
  live a few seconds of frame time).
- bridge_autodetect.mjs simulated a dropped connection with
  bridge.disconnect(), which since 15a0aaa/dc368d6 is the user's deliberate
  Disconnect and rightly does not reconnect by itself (bridge-pause.mjs tests
  that). It now closes the socket underneath, as a real drop does.
- storage-honest.mjs appended stand-in sharedUsage/clearShared to
  model-broker.js. The SDK on main already exports them, so the duplicate
  exports stopped the module from loading, and the three broker checks
  failed. The real ones are renamed before the stand-ins are added.
Changeset8b50ce4fd39fab9c9187b5ab9795f275aeb01c365f49cac092faf308345483c8
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
Parents06c5bad3cc8c

Browse the files at this changeset

10 files changed

modified tests/autoedit_settings.mjs +5 −2
@@ -7,7 +7,8 @@
77 let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
88
99 const b = await chromium.launch();
10-const ctx = await b.newContext();
10+// Etiquetas en español (la interfaz sigue al idioma del navegador desde 7d5e790).
11+const ctx = await b.newContext({ locale: 'es-ES' });
1112 await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1213 const p = await ctx.newPage();
1314 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
@@ -29,7 +30,9 @@
2930 const btnText = await p.locator('#btn-autoedit .ae-txt').innerText();
3031 ok('el botón </> de la barra refleja "Revisar" tras desmarcar en Ajustes', btnText === 'Revisar', btnText);
3132
32-// volver a marcarlo desde la BARRA debe reflejarse en Ajustes al reabrir
33+// volver a marcarlo desde la BARRA debe reflejarse en Ajustes al reabrir. Desde
34+// 43f95b7 el interruptor vive en el menú «⚙︎ Modos»: se abre y se pulsa.
35+if (await p.locator('#modos-menu').isHidden()) await p.click('#btn-modos');
3336 await p.click('#btn-autoedit');
3437 await p.waitForTimeout(150);
3538 await p.click('#btn-settings');
modified tests/bridge_autodetect.mjs +16 −10
@@ -12,7 +12,13 @@
1212
1313 const b = await chromium.launch();
1414 const ctx = await b.newContext();
15-await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
15+await ctx.addInitScript(() => {
16+ try { localStorage.setItem('elffusscode.model', 'rules'); } catch {}
17+ // Para simular una CAÍDA de la conexión hace falta el socket: se apuntan.
18+ const W = window.WebSocket;
19+ window.__sockets = [];
20+ window.WebSocket = class extends W { constructor(...a) { super(...a); window.__sockets.push(this); } };
21+});
1622 const p = await ctx.newPage();
1723 p.on('console', m => { if (/error/i.test(m.type()) && !/favicon/.test(m.text())) console.log(' [console]', m.text()); });
1824 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
@@ -33,16 +39,16 @@
3339 const connected2 = await p.evaluate(async () => (await import('/js/bridge.js')).isConnected());
3440 ok('tras recargar, tryAutoConnect() reconecta con el token guardado', connected2 === true);
3541
36-// 3) simular una caída (bridge.disconnect() en el cliente, el proceso REAL
37-// sigue vivo) y comprobar que startAutoDetect() lo reconecta solo, sin
38-// tocar nada — antes de este cambio esto se quedaba «desconectado» para
39-// siempre hasta que el usuario reabriera Ajustes y pulsara Conectar.
40-await p.evaluate(async () => {
41- const bridge = await import('/js/bridge.js');
42- bridge.disconnect();
43-});
42+// 3) simular una CAÍDA (se cierra el socket por debajo, el proceso REAL sigue
43+// vivo) y comprobar que startAutoDetect() lo reconecta solo, sin tocar nada
44+// — antes de este cambio esto se quedaba «desconectado» para siempre hasta
45+// que el usuario reabriera Ajustes y pulsara Conectar. (Antes se simulaba con
46+// bridge.disconnect(), pero desde c847a2f/1d78303 eso es el «Desconectar» del
47+// usuario, que se respeta y NO reconecta solo: lo prueba bridge-pause.mjs.)
48+await p.evaluate(() => { window.__sockets.at(-1)?.close(); });
49+await p.waitForTimeout(300);
4450 const disconnectedNow = await p.evaluate(async () => (await import('/js/bridge.js')).isConnected());
45-ok('bridge.disconnect() desconecta de verdad', disconnectedNow === false);
51+ok('la caída de la conexión desconecta de verdad', disconnectedNow === false);
4652
4753 await p.waitForTimeout(6000); // startAutoDetect sondea cada 4s
4854 const reconnected = await p.evaluate(async () => (await import('/js/bridge.js')).isConnected());
modified tests/codeedit.mjs +2 −1
@@ -35,7 +35,8 @@
3535 try { await code.edit({ path: 'dup.py', search: 'x = 1', replace: 'x = 2' }); return 'NO LANZÓ ERROR'; }
3636 catch (e) { return 'ERROR: ' + e.message; }
3737 });
38-ok('ambigüedad (aparece 2+ veces) se rechaza con mensaje claro', /más de una vez/.test(r2), r2);
38+// Desde b418762 el error dice dónde aparece (líneas) en vez de «más de una vez».
39+ok('ambigüedad (aparece 2+ veces) se rechaza con mensaje claro', /aparece \d+ veces en dup\.py \(líneas \d+(, \d+)+\)/.test(r2), r2);
3940 const dupUnchanged = await p.evaluate(async () => (await import('/js/tools/code.js')).read({ path: 'dup.py' }));
4041 ok('el fichero ambiguo queda INTACTO (no escribió nada al azar)', dupUnchanged === 'x = 1\nx = 1\nx = 1\n');
4142
modified tests/contrast.mjs +4 −1
@@ -13,7 +13,10 @@
1313 const ctx = await br.newContext();
1414 await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1515 const p = await ctx.newPage({ viewport: { width: 1200, height: 820 } });
16-await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' });
16+// En '/' solo está la landing: desde 77fb41b el IDE oculto (#ide[hidden]) no
17+// se ve detrás, y los botones de Ajustes viven dentro. Se abre el IDE de prueba.
18+await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
19+await p.waitForSelector('#ide:not([hidden])', { timeout: 15000 });
1720 await p.waitForTimeout(800);
1821 // abrir Ajustes
1922 await p.click('#act-settings').catch(() => p.click('#btn-settings'));
modified tests/filelinks2.mjs +1 −1
@@ -8,7 +8,7 @@
88 let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
99
1010 const b = await chromium.launch();
11-const ctx = await b.newContext(); await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
11+const ctx = await b.newContext({ locale: 'es-ES' }); await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1212 const p = await ctx.newPage();
1313 await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' });
1414 await p.evaluate(async () => {
modified tests/goalmode.mjs +7 −4
@@ -8,7 +8,8 @@
88 let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
99
1010 const b = await chromium.launch();
11-const ctx = await b.newContext();
11+// Estados del plan en español (están localizados desde e4415eb).
12+const ctx = await b.newContext({ locale: 'es-ES' });
1213 await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1314 const p = await ctx.newPage();
1415 p.on('pageerror', e => console.log(' pageerror:', e.message.slice(0, 160)));
@@ -19,8 +20,10 @@
1920 ok('el botón 🎯 Goal existe', await p.locator('#btn-goal').count() === 1);
2021 ok('empieza desactivado', !(await p.locator('#btn-goal').evaluate(el => el.classList.contains('on'))));
2122
22-// 2) activarlo lo enciende (misma mecánica que </> Auto)
23-await p.click('#btn-goal');
23+// 2) activarlo lo enciende (misma mecánica que </> Auto). Desde 43f95b7 vive
24+// dentro del menú «⚙︎ Modos»: se abre el menú y se pulsa.
25+const pulsaObjetivo = async () => { if (await p.locator('#modos-menu').isHidden()) await p.click('#btn-modos'); await p.click('#btn-goal'); };
26+await pulsaObjetivo();
2427 await p.waitForTimeout(100);
2528 ok('un clic lo enciende', await p.locator('#btn-goal').evaluate(el => el.classList.contains('on')));
2629 ok('persiste en localStorage', await p.evaluate(() => localStorage.getItem('elffusscode.goalmode') === '1'));
@@ -65,7 +68,7 @@
6568 ok('el estado final persiste tras recargar', /completado|con fallos/i.test(statusAfterReload), statusAfterReload);
6669
6770 // 7) apagar Goal vuelve al chat normal
68-await p.click('#btn-goal');
71+await pulsaObjetivo();
6972 await p.waitForTimeout(100);
7073 ok('un segundo clic lo apaga', !(await p.locator('#btn-goal').evaluate(el => el.classList.contains('on'))));
7174
modified tests/mind.mjs +12 −6
@@ -1,5 +1,8 @@
1-// Mente v2: mundo audio-reactivo + consolas flotantes + nodos clicables +
1+// La Mente: mundo audio-reactivo + estrellas por perfil + nodos clicables +
22 // config de cerebro + persistencia (música/animación) + reporte al chat.
3+// (Era la suite de la Mente v2: las consolas flotantes desaparecieron con la v3,
4+// 603262e, y lo que cada perfil deja ahora es una estrella. mind_stars.mjs
5+// prueba la v3 a fondo.)
36 import { chromium } from 'playwright';
47 import { CHROME_ARGS } from './chrome-args.mjs';
58 const OUT = (process.env.SCRATCH || '/tmp/elffuss-test');
@@ -20,14 +23,17 @@
2023 ok('música solo a petición (botón, sin reproductor cargado)', await p.locator('.mind-music iframe').count()===0 && await p.locator('.mind-music-btn').count()===1);
2124 ok('botón de config del cerebro', await p.locator('#mind-config').count()>0);
2225
23-// inyectar pensamientos + una mejora forjada
24-await p.evaluate(async ()=>{ const m=await import('/js/mind.js');
26+// inyectar pensamientos + una mejora forjada (las estrellas se cuentan en el
27+// mismo paso: viven unos segundos de reloj de fotogramas)
28+const estrellas = await p.evaluate(async ()=>{ const m=await import('/js/mind.js');
29+ const antes = m._debug().starCount;
2530 m.pushThought('ceo',{type:'cycle',n:1,text:'Reparto el trabajo…'});
26- for(const [id,name] of [['arq','Arquitectura'],['cal','Calidad'],['rend','Rendimiento'],['dx','Producto/DX']]){ m.pushThought(id,{type:'open',name,focus:'foco'}); m.pushThought(id,{type:'token',text:'analizo '+name+' y propongo una mejora concreta en app.js. '}); m.pushThought(id,{type:'done'}); }
31+ for(const [id,name] of [['arq','Arquitectura'],['cal','Calidad'],['rend','Rendimiento'],['dx','Producto/DX']]){ m.pushThought(id,{type:'open',name,focus:'foco'}); m.pushThought(id,{type:'token',text:'analizo '+name+' y propongo una mejora concreta en app.js.\n'}); m.pushThought(id,{type:'done'}); }
2732 m.pushThought('ceo',{type:'built',text:'Guardado en .elffuss/soul/mejoras-001.md',path:'.elffuss/soul/mejoras-001.md',proposals:[{dept:'Arquitectura',text:'extraer helper'},{dept:'Calidad',text:'añadir test'}]});
33+ return { antes, despues: m._debug().starCount };
2834 });
2935 await p.waitForTimeout(1000);
30-ok('consolas flotantes (ancladas al mundo)', await p.locator('.mind-console').count()>=4, await p.locator('.mind-console').count()+'');
36+ok('cada perfil deja su estrella (Mente v3)', estrellas.despues - estrellas.antes >= 4, `${estrellas.antes}→${estrellas.despues}`);
3137 ok('nodo de pensamiento clicable creado', await p.evaluate(()=>document.querySelectorAll('.mind-node-label').length>0));
3238
3339 // abrir el panel de config y reprogramar la misión
@@ -46,5 +52,5 @@
4652 await p.locator('#activity img').click(); await p.waitForTimeout(400);
4753 ok('al reabrir NO se recrea (persistencia música/animación)', await p.evaluate(()=>document.querySelectorAll('#mind-overlay').length===1));
4854 console.log('captura → mind2.png');
49-console.log(fails?`\n❌ ${fails} FALLO(S)`:'\n✅ MENTE v2 OK');
55+console.log(fails?`\n❌ ${fails} FALLO(S)`:'\n✅ MENTE OK');
5056 await b.close(); process.exit(fails?1:0);
modified tests/sendfeedback.mjs +2 −1
@@ -23,7 +23,8 @@
2323 await p.fill('#prompt', 'hola');
2424 await p.press('#prompt', 'Enter');
2525 await p.waitForTimeout(150);
26-ok('el botón de enviar muestra estado "pensando" (clase sending + disabled)', await p.locator('#btn-send').evaluate(el => el.classList.contains('sending') && el.disabled));
26+// Desde 2421c1b el botón NO se deshabilita mientras genera: pasa a ■ Parar.
27+ok('el botón de enviar pasa a ■ PARAR mientras genera (sending + is-stop, clicable)', await p.locator('#btn-send').evaluate(el => el.classList.contains('sending') && el.classList.contains('is-stop') && !el.disabled));
2728 await p.waitForTimeout(1500);
2829 ok('al terminar, el botón vuelve a su estado normal', await p.locator('#btn-send').evaluate(el => !el.classList.contains('sending') && !el.disabled));
2930
modified tests/storage-honest.mjs +9 −3
@@ -128,8 +128,8 @@
128128 });
129129 ok('1 · con «Guardar solo», el mensaje nuevo acaba en .elffuss/code/ sin pulsar Guardar', disco.razon === 'auto' && disco.contiene, JSON.stringify(disco));
130130
131-// 3 · con un SDK de broker que SÍ sabe del almacén compartido (como el de main)
132-// Doble local: el model-broker.js de este árbol más sharedUsage/clearShared que
131+// 3 · con el SDK de broker que sabe del almacén compartido (el de main)
132+// Doble local: el model-broker.js de este árbol con sharedUsage/clearShared que
133133 // apuntan lo que se les pide, y un registro del motor con dos hosts de pesos.
134134 {
135135 const DOBLE = `
@@ -145,7 +145,13 @@
145145 await c2.route(BROKERS, r => { brokersPedidos.push(r.request().url()); return r.fulfill({ status: 200, contentType: 'text/html', body: BROKER_FALSO }); });
146146 await c2.route('**/js/runtime/model-broker.js*', async route => {
147147 const r = await route.fetch();
148- await route.fulfill({ response: r, body: (await r.text()) + DOBLE, headers: { ...r.headers(), 'content-type': 'text/javascript' } });
148+ // El SDK de main YA trae sharedUsage/clearShared: los suyos se renombran y se
149+ // ponen los dobles. Añadir los dobles sin más duplicaba los export y el
150+ // módulo entero no cargaba (y model-cache.js se quedaba sin broker).
151+ const propio = (await r.text())
152+ .replace(/export async function sharedUsage\(/, 'async function sharedUsageReal(')
153+ .replace(/export async function clearShared\(/, 'async function clearSharedReal(');
154+ await route.fulfill({ response: r, body: propio + DOBLE, headers: { ...r.headers(), 'content-type': 'text/javascript' } });
149155 });
150156 await c2.route('**/js/engine/registro.js*', r => r.fulfill({ status: 200, contentType: 'text/javascript',
151157 body: "export const MODELS = {}; export async function disponible() { return false; } export function origenesAlmacen() { return ['https://m1.elffuss.com/', 'https://m2.elffuss.com/']; }" }));
modified tests/streampreview.mjs +1 −1
@@ -7,7 +7,7 @@
77 let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
88
99 const b = await chromium.launch();
10-const ctx = await b.newContext(); await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
10+const ctx = await b.newContext({ locale: 'es-ES' }); await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1111 const p = await ctx.newPage();
1212 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); await p.waitForTimeout(1500);
1313