utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 8b50ce4fd39fab9c9187b5ab9795f275aeb01c365f49cac092faf308345483c8 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00 |
| Parents | 06c5bad3cc8c |
10 files changed
modified tests/autoedit_settings.mjs +5 −2
| @@ -7,7 +7,8 @@ | ||
| 7 | 7 | let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; |
| 8 | 8 | |
| 9 | 9 | 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' }); | |
| 11 | 12 | await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); |
| 12 | 13 | const p = await ctx.newPage(); |
| 13 | 14 | await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); |
| @@ -29,7 +30,9 @@ | ||
| 29 | 30 | const btnText = await p.locator('#btn-autoedit .ae-txt').innerText(); |
| 30 | 31 | ok('el botón </> de la barra refleja "Revisar" tras desmarcar en Ajustes', btnText === 'Revisar', btnText); |
| 31 | 32 | |
| 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'); | |
| 33 | 36 | await p.click('#btn-autoedit'); |
| 34 | 37 | await p.waitForTimeout(150); |
| 35 | 38 | await p.click('#btn-settings'); |
modified tests/bridge_autodetect.mjs +16 −10
| @@ -12,7 +12,13 @@ | ||
| 12 | 12 | |
| 13 | 13 | const b = await chromium.launch(); |
| 14 | 14 | 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 | +}); | |
| 16 | 22 | const p = await ctx.newPage(); |
| 17 | 23 | p.on('console', m => { if (/error/i.test(m.type()) && !/favicon/.test(m.text())) console.log(' [console]', m.text()); }); |
| 18 | 24 | await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); |
| @@ -33,16 +39,16 @@ | ||
| 33 | 39 | const connected2 = await p.evaluate(async () => (await import('/js/bridge.js')).isConnected()); |
| 34 | 40 | ok('tras recargar, tryAutoConnect() reconecta con el token guardado', connected2 === true); |
| 35 | 41 | |
| 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); | |
| 44 | 50 | 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); | |
| 46 | 52 | |
| 47 | 53 | await p.waitForTimeout(6000); // startAutoDetect sondea cada 4s |
| 48 | 54 | const reconnected = await p.evaluate(async () => (await import('/js/bridge.js')).isConnected()); |
modified tests/codeedit.mjs +2 −1
| @@ -35,7 +35,8 @@ | ||
| 35 | 35 | try { await code.edit({ path: 'dup.py', search: 'x = 1', replace: 'x = 2' }); return 'NO LANZÓ ERROR'; } |
| 36 | 36 | catch (e) { return 'ERROR: ' + e.message; } |
| 37 | 37 | }); |
| 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); | |
| 39 | 40 | const dupUnchanged = await p.evaluate(async () => (await import('/js/tools/code.js')).read({ path: 'dup.py' })); |
| 40 | 41 | ok('el fichero ambiguo queda INTACTO (no escribió nada al azar)', dupUnchanged === 'x = 1\nx = 1\nx = 1\n'); |
| 41 | 42 |
modified tests/contrast.mjs +4 −1
| @@ -13,7 +13,10 @@ | ||
| 13 | 13 | const ctx = await br.newContext(); |
| 14 | 14 | await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); |
| 15 | 15 | 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 }); | |
| 17 | 20 | await p.waitForTimeout(800); |
| 18 | 21 | // abrir Ajustes |
| 19 | 22 | await p.click('#act-settings').catch(() => p.click('#btn-settings')); |
modified tests/filelinks2.mjs +1 −1
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; |
| 9 | 9 | |
| 10 | 10 | 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 {} }); | |
| 12 | 12 | const p = await ctx.newPage(); |
| 13 | 13 | await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); |
| 14 | 14 | await p.evaluate(async () => { |
modified tests/goalmode.mjs +7 −4
| @@ -8,7 +8,8 @@ | ||
| 8 | 8 | let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; |
| 9 | 9 | |
| 10 | 10 | 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' }); | |
| 12 | 13 | await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} }); |
| 13 | 14 | const p = await ctx.newPage(); |
| 14 | 15 | p.on('pageerror', e => console.log(' pageerror:', e.message.slice(0, 160))); |
| @@ -19,8 +20,10 @@ | ||
| 19 | 20 | ok('el botón 🎯 Goal existe', await p.locator('#btn-goal').count() === 1); |
| 20 | 21 | ok('empieza desactivado', !(await p.locator('#btn-goal').evaluate(el => el.classList.contains('on')))); |
| 21 | 22 | |
| 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(); | |
| 24 | 27 | await p.waitForTimeout(100); |
| 25 | 28 | ok('un clic lo enciende', await p.locator('#btn-goal').evaluate(el => el.classList.contains('on'))); |
| 26 | 29 | ok('persiste en localStorage', await p.evaluate(() => localStorage.getItem('elffusscode.goalmode') === '1')); |
| @@ -65,7 +68,7 @@ | ||
| 65 | 68 | ok('el estado final persiste tras recargar', /completado|con fallos/i.test(statusAfterReload), statusAfterReload); |
| 66 | 69 | |
| 67 | 70 | // 7) apagar Goal vuelve al chat normal |
| 68 | -await p.click('#btn-goal'); | |
| 71 | +await pulsaObjetivo(); | |
| 69 | 72 | await p.waitForTimeout(100); |
| 70 | 73 | ok('un segundo clic lo apaga', !(await p.locator('#btn-goal').evaluate(el => el.classList.contains('on')))); |
| 71 | 74 |
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 + | |
| 2 | 2 | // 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.) | |
| 3 | 6 | import { chromium } from 'playwright'; |
| 4 | 7 | import { CHROME_ARGS } from './chrome-args.mjs'; |
| 5 | 8 | const OUT = (process.env.SCRATCH || '/tmp/elffuss-test'); |
| @@ -20,14 +23,17 @@ | ||
| 20 | 23 | 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); |
| 21 | 24 | ok('botón de config del cerebro', await p.locator('#mind-config').count()>0); |
| 22 | 25 | |
| 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; | |
| 25 | 30 | 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'}); } | |
| 27 | 32 | 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 }; | |
| 28 | 34 | }); |
| 29 | 35 | 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}`); | |
| 31 | 37 | ok('nodo de pensamiento clicable creado', await p.evaluate(()=>document.querySelectorAll('.mind-node-label').length>0)); |
| 32 | 38 | |
| 33 | 39 | // abrir el panel de config y reprogramar la misión |
| @@ -46,5 +52,5 @@ | ||
| 46 | 52 | await p.locator('#activity img').click(); await p.waitForTimeout(400); |
| 47 | 53 | ok('al reabrir NO se recrea (persistencia música/animación)', await p.evaluate(()=>document.querySelectorAll('#mind-overlay').length===1)); |
| 48 | 54 | 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'); | |
| 50 | 56 | await b.close(); process.exit(fails?1:0); |
modified tests/sendfeedback.mjs +2 −1
| @@ -23,7 +23,8 @@ | ||
| 23 | 23 | await p.fill('#prompt', 'hola'); |
| 24 | 24 | await p.press('#prompt', 'Enter'); |
| 25 | 25 | 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)); | |
| 27 | 28 | await p.waitForTimeout(1500); |
| 28 | 29 | ok('al terminar, el botón vuelve a su estado normal', await p.locator('#btn-send').evaluate(el => !el.classList.contains('sending') && !el.disabled)); |
| 29 | 30 |
modified tests/storage-honest.mjs +9 −3
| @@ -128,8 +128,8 @@ | ||
| 128 | 128 | }); |
| 129 | 129 | ok('1 · con «Guardar solo», el mensaje nuevo acaba en .elffuss/code/ sin pulsar Guardar', disco.razon === 'auto' && disco.contiene, JSON.stringify(disco)); |
| 130 | 130 | |
| 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 | |
| 133 | 133 | // apuntan lo que se les pide, y un registro del motor con dos hosts de pesos. |
| 134 | 134 | { |
| 135 | 135 | const DOBLE = ` |
| @@ -145,7 +145,13 @@ | ||
| 145 | 145 | await c2.route(BROKERS, r => { brokersPedidos.push(r.request().url()); return r.fulfill({ status: 200, contentType: 'text/html', body: BROKER_FALSO }); }); |
| 146 | 146 | await c2.route('**/js/runtime/model-broker.js*', async route => { |
| 147 | 147 | 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' } }); | |
| 149 | 155 | }); |
| 150 | 156 | await c2.route('**/js/engine/registro.js*', r => r.fulfill({ status: 200, contentType: 'text/javascript', |
| 151 | 157 | 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 @@ | ||
| 7 | 7 | let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; |
| 8 | 8 | |
| 9 | 9 | 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 {} }); | |
| 11 | 11 | const p = await ctx.newPage(); |
| 12 | 12 | await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); await p.waitForTimeout(1500); |
| 13 | 13 |