Elffuss BraidHub

utopia-ia/elffuss-code public

178a8a01c6e9 · 6.8 KiBRawPermalink
1// Avisos que se entienden y textos en el idioma de la interfaz.
2//
3// 1. Fallo al cargar el modelo: en palabras de persona («sin conexión…», no
4// «Failed to fetch»), en una región viva, con «Reintentar» que reintenta.
5// 2. Skills: sin conexión, «Explorar» lo dice dentro del panel con
6// «Reintentar»; un repo que no vale se dice en línea, sin alert().
7// 3. El modo Básico manda a ⚙️ Ajustes → Cerebro, no a un «selector 🧠» que
8// no existe.
9// 4. Abierto desde una notificación con la app cerrada (?notif=open), la
10// Mente aparece y la URL queda limpia.
11// 5. En inglés: Enviar/Parar, «limpiar» del terminal, Modo Objetivo y
12// Feedback de Ajustes, y la barra de menús, ya no salen en español.
13// Nada sale a la red: el modelo y GitHub van interceptados.
14//
15// BASE=http://127.0.0.1:8898 node tests/messages-ux.mjs
16import { chromium } from 'playwright';
17const BASE = process.env.BASE || 'http://localhost:8799';
18let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
19
20const FALLA = `window.__cargas = (window.__cargas || 0);
21export const name = 'onnx que falla'; export function configure() {}
22export async function load() { window.__cargas++; throw new TypeError('Failed to fetch'); }
23export async function chat() { return ''; }`;
24
25const b = await chromium.launch();
26const errs = [];
27const abre = async (locale, query = '') => {
28 const ctx = await b.newContext({ locale });
29 await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} window.__alerts = 0; window.alert = () => { window.__alerts++; }; });
30 await ctx.route('**/js/providers/onnx.js*', r => r.fulfill({ status: 200, contentType: 'text/javascript', body: FALLA }));
31 await ctx.route(/api\.github\.com|raw\.githubusercontent\.com/, r => r.abort());
32 await ctx.route(/soundcloud/, r => r.abort());
33 const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } });
34 p.on('pageerror', e => errs.push(e.message.slice(0, 160)));
35 await p.goto(BASE + '/?test-opfs' + query, { waitUntil: 'domcontentloaded' });
36 await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 });
37 return { ctx, p };
38};
39
40let { ctx, p } = await abre('es-ES');
41
42// 3 · ayuda del modo Básico
43await p.fill('#prompt', 'hola');
44await p.press('#prompt', 'Enter');
45await p.waitForFunction(() => !window.elffussClaw.conv.isBusy(), null, { timeout: 8000 });
46const ayuda = await p.evaluate(() => document.getElementById('chat-log').innerText);
47ok('3 · el modo Básico manda a ⚙️ Ajustes → Cerebro', /Ajustes → Cerebro/.test(ayuda) && !/selector 🧠/.test(ayuda), ayuda.slice(-160));
48
49// 1 · fallo al cargar el modelo
50await p.click('#btn-settings');
51await p.locator('#settings-panel .model-card', { hasText: 'Qwen3.5-0.8B' }).first().click();
52await p.waitForFunction(() => /No pude cargar/.test(document.getElementById('model-progress-text').textContent), null, { timeout: 8000 }).catch(() => {});
53const pildora = await p.evaluate(() => ({ txt: document.getElementById('model-progress-text').textContent, rol: document.getElementById('model-progress').getAttribute('role'), reintentar: !!document.querySelector('#model-progress .mp-acciones button') }));
54ok('1 · el fallo se dice en palabras de persona, no «Failed to fetch»', /no se pudo descargar/.test(pildora.txt) && !/Failed to fetch/.test(pildora.txt), JSON.stringify(pildora));
55ok('1 · la píldora es una región viva con «Reintentar»', pildora.rol === 'status' && pildora.reintentar, JSON.stringify(pildora));
56await p.locator('#model-progress .mp-acciones button', { hasText: 'Reintentar' }).click();
57await p.waitForTimeout(600);
58ok('1 · «Reintentar» vuelve a intentar la carga', await p.evaluate(() => window.__cargas) === 2, String(await p.evaluate(() => window.__cargas)));
59
60// 2 · skills sin conexión y repo que no vale
61await p.evaluate(() => document.getElementById('settings-panel').hidden || document.getElementById('btn-settings').click());
62await p.evaluate(() => window.elffussClaw.skills && document.getElementById('act-skills').click());
63await p.waitForTimeout(500);
64await p.locator('#settings-panel .sk-row button', { hasText: 'Explorar' }).first().click();
65await p.waitForSelector('#settings-panel .sk-browse .sk-msg', { timeout: 8000 }).catch(() => {});
66const skill = await p.evaluate(() => ({ msg: document.querySelector('#settings-panel .sk-browse .sk-msg')?.textContent || '', reintentar: !!document.querySelector('#settings-panel .sk-browse button') }));
67ok('2 · sin conexión, «Explorar» lo dice dentro del panel con «Reintentar»', /sin conexión/.test(skill.msg) && skill.reintentar && !/FAILED TO FETCH/.test(skill.msg), JSON.stringify(skill));
68await p.locator('#settings-panel input[aria-label="Añadir repo"]').fill('esto no es un repo');
69await p.locator('#settings-panel button', { hasText: 'Añadir repo' }).click();
70await p.waitForTimeout(300);
71const repo = await p.evaluate(() => ({ alerts: window.__alerts, msg: [...document.querySelectorAll('#settings-panel .sk-msg')].map(n => n.textContent).join(' | ') }));
72ok('2 · un repo que no vale se dice en línea, sin alert()', repo.alerts === 0 && /⚠️/.test(repo.msg), JSON.stringify(repo));
73await ctx.close();
74
75// 4 · desde una notificación
76({ ctx, p } = await abre('es-ES', '&notif=open'));
77await p.waitForSelector('#mind-overlay', { timeout: 45000 }).catch(() => {});
78const notif = await p.evaluate(() => ({ mente: !!document.getElementById('mind-overlay') && getComputedStyle(document.getElementById('mind-overlay')).display !== 'none', url: location.search }));
79ok('4 · ?notif=open abre la Mente y limpia la URL', notif.mente && !/notif/.test(notif.url), JSON.stringify(notif));
80await ctx.close();
81
82// 5 · en inglés
83({ ctx, p } = await abre('en-US'));
84await p.click('#btn-settings');
85await p.waitForTimeout(400);
86const en = await p.evaluate(() => ({
87 enviar: document.getElementById('btn-send').title,
88 limpiar: document.getElementById('term-clear').textContent,
89 menus: [...document.querySelectorAll('#menubar button')].map(b => b.textContent).join(','),
90 goal: document.querySelector('#perm-goalmode').closest('label').textContent.trim(),
91 tel: document.querySelector('#tel-enabled').closest('label').textContent.trim(),
92 enviarFeedback: document.getElementById('tel-send').textContent,
93}));
94ok('5 · en inglés, nada de lo de antes sale en español', en.enviar === 'Send' && en.limpiar === 'clear' && en.menus === 'File,Edit,View,Git' && /^Treat the next message/.test(en.goal) && /^Automatically send/.test(en.tel) && en.enviarFeedback === 'Send', JSON.stringify(en));
95await ctx.close();
96
97console.log('\n errores JS:', errs[0] || 'ninguno');
98ok('sin errores de página', errs.length === 0, errs.join(' | '));
99console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ AVISOS QUE SE ENTIENDEN, EN SU IDIOMA');
100await b.close();
101process.exit(fails ? 1 : 0);