Elffuss BraidHub

utopia-ia/elffuss-claw public

main · 12.3 KiBRawPermalink
1// En inglés (en-US), lo que se rehízo en la auditoría de UX habla inglés:
2// · los avisos del selector de modelo (Básico, un cerebro que no carga);
3// · la respuesta del modo básico, con su enlace al selector de modelo;
4// · «What's stored» en Ajustes;
5// · el error de la bóveda al guardar sin nombre;
6// · el velocímetro (chip, panel y su nombre accesible), con un motor de prueba;
7// · lo que devuelven las herramientas (y se ve en el chat), lo que cuenta el
8// cerebro (ceo.js) y los textos de skills.js;
9// · el tablero del copiloto (lo que enseña; la skill y su contrato con el
10// modelo no cambian);
11// · las fuentes de serie de Skills, la ayuda de los modelos externos en
12// Ajustes, y los perfiles y la misión de serie de la Mente.
13// Antes todo eso salía en español con la página en inglés.
14//
15// BASE=http://localhost:8743 node tests/ux-ingles.mjs
16import { navegador, contexto, pagina, ok, hasta, escribir, reposo, avisos, fin } from './ux-comun.mjs';
17
18const b = await navegador();
19const ESPANOL = /\b(sin modelo|No se pudo|Estoy en modo|selector de modelo|Generadas|Conversación|Bóveda|Faltan|Velocidad|leyendo|escribiendo|Pulsa)\b/;
20
21const { ctx } = await contexto(b, {
22 locale: 'en-US', grants: [],
23 extraInit: { 'elffuss.providers': JSON.stringify({ openai: { enabled: true, baseURL: 'https://api.openai.com/v1', model: 'gpt-4o-mini', apiKey: '' } }) },
24});
25const { p, errores } = await pagina(ctx);
26const elegir = id => p.evaluate(id => { const s = document.getElementById('model-select'); s.value = id; s.dispatchEvent(new Event('change')); }, id);
27
28// ── selector de modelo ──────────────────────────────────────────────────────
29await elegir('rules');
30ok('choosing Basic says so in English', await hasta(async () => (await avisos(p)).some(t => t === 'Basic mode: no model, direct commands.')),
31 (await avisos(p)).join(' | '));
32await hasta(() => p.evaluate(() => !document.getElementById('model-select').disabled));
33await elegir('ext:openai'); // sin clave: no carga, y no había otro cerebro
34ok('a brain that does not load says why in English', await hasta(async () =>
35 (await avisos(p)).some(t => /^⚠️ Could not load OpenAI: the API key is missing \(advanced settings\)$/.test(t))), (await avisos(p)).join(' | '));
36
37// ── modo básico ─────────────────────────────────────────────────────────────
38await hasta(() => p.evaluate(() => document.getElementById('model-select').value === 'rules' && !document.getElementById('model-select').disabled));
39await escribir(p, 'hola');
40await reposo(p);
41const respuesta = await p.locator('#log .msg.assistant').last();
42const texto = await respuesta.innerText();
43ok('the Basic-mode reply is in English and says the commands are in Spanish', /I am in Basic mode/.test(texto) && /written in Spanish/.test(texto) && !/Estoy en modo/.test(texto), texto.slice(0, 160));
44ok('…and links to the model picker', await respuesta.locator('a[href="#/modelo"]').innerText().catch(() => '') === 'model picker');
45
46// ── Settings › What's stored ────────────────────────────────────────────────
47await p.click('#tabs button[data-tab="ajustes"]');
48const tarjeta = p.locator('#panel-ajustes .card', { hasText: 'Wipe browser data' });
49ok('“What’s stored” names the stores in English', await hasta(async () => {
50 const t = await tarjeta.innerText().catch(() => '');
51 return /Generated apps/.test(t) && /Conversation/.test(t) && /Vault \(encrypted\)/.test(t) && !/Apps generadas|Bóveda/.test(t);
52}), await tarjeta.innerText().catch(() => ''));
53
54// ── Skills: las fuentes de serie ────────────────────────────────────────────
55await p.click('#tabs button[data-tab="skills"]');
56const etiquetasFuentes = () => p.$$eval('#panel-skills .skills-fuentes .card > .row > b', bs => bs.map(b => b.textContent));
57await hasta(async () => (await etiquetasFuentes()).length === 6);
58const fuentes = await etiquetasFuentes();
59ok('the six built-in Skills sources are labelled in English', fuentes.length === 6 && fuentes.includes('Community · Mega collection (1000+ skills)')
60 && fuentes.includes('3D in the browser · Three.js (works in Claw)') && !fuentes.some(f => /Comunidad|navegador|funciona|oficial|solo referencia/.test(f)),
61 JSON.stringify(fuentes));
62
63// ── Settings › External models: la ayuda de cada proveedor ─────────────────
64await p.click('#tabs button[data-tab="ajustes"]');
65await p.locator('#panel-ajustes .ext-block > summary').click();
66const ext = await p.locator('#panel-ajustes .ext-block').innerText();
67ok('Settings › External models: the provider help texts are in English', /Your sk-… key\. It stays in your browser/.test(ext)
68 && /Ollama on your machine/.test(ext) && /The header for direct browser access/.test(ext)
69 && !/Tu clave|Se queda|Arráncalo|Se envía/.test(ext), ext.slice(0, 400));
70
71// ── la Mente: perfiles y misión de serie ────────────────────────────────────
72const mente = await p.evaluate(async () => {
73 const ceo = await import('/js/ceo.js');
74 return { perfiles: ceo.getProfiles().map(x => [x.name, x.focus]), mision: ceo.getMission() };
75});
76ok('the Mind’s default departments, their focus and the mission are in English', mente.perfiles.map(x => x[0]).join() === 'Organization,Productivity,Memory'
77 && /authorized files and folders/.test(mente.perfiles[0][1]) && /^Review your space/.test(mente.mision)
78 && !JSON.stringify(mente).match(/Organización|Productividad|carpetas|Revisar/), JSON.stringify(mente).slice(0, 300));
79
80// ── Vault: guardar sin nombre ───────────────────────────────────────────────
81await p.click('#tabs button[data-tab="vault"]');
82await p.fill('#vault-master', 'test-password-1');
83await p.press('#vault-master', 'Enter');
84await hasta(() => p.evaluate(() => !!document.getElementById('vault-name')));
85await p.fill('#panel-vault input[type=password]', 'secret-without-name');
86await p.press('#panel-vault input[type=password]', 'Enter');
87ok('saving a secret without a name says so in English', await hasta(async () => (await avisos(p)).some(t => /The name or the secret is missing/.test(t))),
88 (await avisos(p)).join(' | '));
89
90// ── velocímetro ─────────────────────────────────────────────────────────────
91await p.evaluate(async () => {
92 const vm = await import('/js/velocimetro.js');
93 vm.usarTraductor((await import('/js/i18n.js')).t); // lo que hace el kernel al montarlo
94 vm.montar({
95 alMedir: () => () => {},
96 ultimaMedida: () => ({ prefillTokS: 300, genTokS: 20, ttftMs: 900, genTokens: 50, procesados: 400, reusados: 3, enCurso: false }),
97 });
98});
99const chip = p.locator('#speed-chip');
100ok('speed chip title in English', /^Writing at 20\.0 tok\/s · the prompt was read at 300 tok\/s · first letter after 900 ms\. Click to see the chart\.$/.test(await chip.getAttribute('title') || ''),
101 await chip.getAttribute('title'));
102await chip.click();
103const panel = await p.evaluate(() => ({ text: document.getElementById('speed-panel').innerText, label: document.getElementById('speed-panel').getAttribute('aria-label') }));
104ok('speed panel and its accessible name in English', panel.label === 'Speed of this machine' && /tok\/s reading the prompt/.test(panel.text)
105 && /3 reused/.test(panel.text) && !ESPANOL.test(panel.text), JSON.stringify(panel).slice(0, 300));
106
107// ── herramientas, cerebro y skills ──────────────────────────────────────────
108const herramientas = await p.evaluate(async () => {
109 const { runTool } = await import('/js/tools/index.js');
110 const r = async (n, a) => { try { return await runTool(n, a); } catch (e) { return 'ERROR ' + e.message; } };
111 return {
112 memoria: await r('memory.list', {}), tareas: await r('tasks.list', {}),
113 automatizaciones: await r('fs.watch_list', {}), boveda: await r('vault.list', {}), app: await r('app.open', { name: 'nada' }),
114 desconocida: await r('no.existe', {}), skill: await r('skill.get', { name: 'nada' }),
115 };
116});
117ok('tool results and errors are in English', /I do not remember anything yet/.test(herramientas.memoria) && herramientas.tareas === 'No scheduled tasks.'
118 && /^No automations\./.test(herramientas.automatizaciones)
119 && /There is no app “nada”/.test(herramientas.app) && /Unknown tool: no\.existe/.test(herramientas.desconocida)
120 && /There is no skill “nada”/.test(herramientas.skill) && !Object.values(herramientas).some(v => ESPANOL.test(v) || /No hay|No existe|Falta/.test(v)),
121 JSON.stringify(herramientas).slice(0, 400));
122const skillTxt = await p.evaluate(async () => (await import('/js/skills.js')).usageMessage({ name: 'demo', description: '' }));
123ok('the “how to use it” message of a skill is in English', /Skill “demo” installed/.test(skillTxt) && /To use it, ask me/.test(skillTxt), skillTxt);
124const cerebro = await p.evaluate(async () => {
125 const ceo = await import('/js/ceo.js');
126 const vistos = [];
127 const { onEvent } = { onEvent: (ch, ev) => vistos.push(ev.text) };
128 ceo.init({ onEvent });
129 ceo.enable(); ceo.disable();
130 return vistos;
131});
132ok('what the brain says (on watch, paused) is in English', cerebro.includes('CEO on watch — I will work while you are idle') && cerebro.includes('CEO paused'),
133 JSON.stringify(cerebro));
134
135ok('no page errors', errores.length === 0, errores.slice(0, 3).join(' | '));
136
137// ── tablero del copiloto, con un Translator de mentira (en inglés) ──────────
138{
139 const TRANSLATOR = 'https://translator.elffuss.com';
140 const STUB = '<!doctype html><html><body>stub<script>window.__msgs=[];addEventListener("message",e=>window.__msgs.push({origin:e.origin,data:e.data}));</script></body></html>';
141 const { ctx: c2 } = await contexto(b, { locale: 'en-US', grants: ['apps'],
142 rutas: async (url, route) => { if (!url.startsWith(TRANSLATOR + '/')) return false; await route.fulfill({ status: 200, contentType: 'text/html', body: STUB }); return true; } });
143 const stub = await c2.newPage();
144 await stub.goto(TRANSLATOR + '/copilot-test.html');
145 const { BASE } = await import('./ux-comun.mjs');
146 const [claw] = await Promise.all([c2.waitForEvent('page'), stub.evaluate(u => { window.__claw = window.open(u, 'claw'); }, BASE + '/?copilot=1&skill=ficha')]);
147 await claw.waitForFunction(() => !!window.elffuss?.agent, null, { timeout: 15000 });
148 await hasta(() => stub.evaluate(() => window.__msgs.some(m => m.data?.kind === 'copilot-ready')));
149 await stub.evaluate(o => window.__claw.postMessage({ kind: 'copilot-init', skill: 'ficha', sellerLangName: 'English' }, o), new URL(BASE).origin);
150 const tablero = () => claw.frames().find(f => f !== claw.mainFrame() && f.url() === 'about:srcdoc');
151 ok('the copilot board is in English (title, labels, live box, export)', await hasta(async () => {
152 const f = tablero(); if (!f) return false;
153 // textContent y no innerText: la hoja del tablero pasa a MAYÚSCULAS algunas
154 // etiquetas, e innerText devuelve el texto ya transformado.
155 const t = await f.evaluate(() => ['h1', '.sub', '#slots', '.advice', '#exp'].map(s => document.querySelector(s)?.textContent || '').join(' | ')).catch(() => '');
156 return /Client record/.test(t) && /Captured data/.test(t) && /Company/.test(t) && /Waiting for the conversation to start/.test(t)
157 && /Export to Excel/.test(t) && !/Ficha de cliente|Datos capturados|Empresa|Esperando/.test(t);
158 }), await tablero()?.evaluate(() => document.body.textContent.slice(0, 300)).catch(() => '?'));
159 const proyectado = await stub.evaluate(() => window.__msgs.find(m => m.data?.kind === 'surface')?.data?.title || '');
160 ok('…and so is the board projected to the Translator', /Client record/.test(proyectado), proyectado);
161 await c2.close();
162}
163
164await fin(b, 'INGLÉS: lo rehecho en la auditoría habla inglés con la página en inglés');