utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | d7571aecdc4a0ebc084ec38b8de849a1747bd3df4f62a040b2bf0143cde0c52f |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:10 +02:00 |
| Parents | b68cefab2bf2 |
4 files changed
added tests/a11y-names.mjs +70 −0
| @@ -0,0 +1,70 @@ | ||
| 1 | +// Nombres y valores que oye un lector de pantalla, en tres controles que los | |
| 2 | +// tenían mal: | |
| 3 | +// 1. «Modos» con Auto encendido (el de por defecto) decía «Modos: ninguno | |
| 4 | +// activo» mientras el menú lo enseñaba marcado. | |
| 5 | +// 2. Una pestaña del editor se llamaba «app.js Cerrar app.js»: sin nombre | |
| 6 | +// propio, el del botón × que lleva dentro se sumaba al suyo. | |
| 7 | +// 3. El separador del terminal no tenía aria-valuenow hasta el primer | |
| 8 | +// arrastre, ni aria-valuemax nunca. | |
| 9 | +// | |
| 10 | +// BASE=http://localhost:8799 node tests/a11y-names.mjs | |
| 11 | +import { chromium } from 'playwright'; | |
| 12 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 13 | +let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 14 | + | |
| 15 | +const b = await chromium.launch(); | |
| 16 | +const ctx = await b.newContext({ locale: 'es-ES' }); | |
| 17 | +await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); localStorage.removeItem('elffusscode.autoedit'); } catch {} }); | |
| 18 | +const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } }); | |
| 19 | +const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0, 160))); | |
| 20 | +await p.goto(BASE + '/manifest.json'); | |
| 21 | +await p.evaluate(async () => { | |
| 22 | + const root = await navigator.storage.getDirectory(); | |
| 23 | + const w = await (await root.getFileHandle('app.js', { create: true })).createWritable(); await w.write('export const a = 1;\n'); await w.close(); | |
| 24 | +}); | |
| 25 | +await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); | |
| 26 | +await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 }); | |
| 27 | + | |
| 28 | +// 1 · Modos | |
| 29 | +const nombreModos = () => p.evaluate(() => document.getElementById('btn-modos').getAttribute('aria-label')); | |
| 30 | +const conAuto = await nombreModos(); | |
| 31 | +ok('1 · con Auto encendido, «Modos» lo dice (no «ninguno activo»)', /Auto/.test(conAuto) && !/ninguno/.test(conAuto), conAuto); | |
| 32 | +await p.click('#btn-modos'); await p.click('#btn-autoedit'); | |
| 33 | +const conRevisar = await nombreModos(); | |
| 34 | +ok('1 · con Auto apagado dice «revisar antes de escribir»', /revisar antes de escribir/.test(conRevisar) && !/Auto/.test(conRevisar), conRevisar); | |
| 35 | +await p.click('#btn-goal'); | |
| 36 | +const conObjetivo = await nombreModos(); | |
| 37 | +ok('1 · y suma los demás modos encendidos', /revisar antes de escribir/.test(conObjetivo) && /objetivo/.test(conObjetivo), conObjetivo); | |
| 38 | +await p.click('#btn-goal'); await p.click('#btn-autoedit'); await p.keyboard.press('Escape'); | |
| 39 | + | |
| 40 | +// 2 · pestaña del editor | |
| 41 | +await p.locator('#tree .file', { hasText: 'app.js' }).first().click(); | |
| 42 | +await p.waitForSelector('#tabs-bar .tab.active'); | |
| 43 | +const pestana = () => p.evaluate(() => { const t = document.querySelector('#tabs-bar .tab.active'); return { nombre: t.getAttribute('aria-label'), x: t.querySelector('.tab-x')?.getAttribute('aria-label') }; }); | |
| 44 | +const limpia = await pestana(); | |
| 45 | +ok('2 · la pestaña se llama como el fichero, sin el «Cerrar…» del ×', limpia.nombre === 'app.js', JSON.stringify(limpia)); | |
| 46 | +ok('2 · …y el × conserva su propio nombre', limpia.x === 'Cerrar app.js', JSON.stringify(limpia)); | |
| 47 | +// una edición de verdad en el editor (como teclear) | |
| 48 | +await p.evaluate(() => window.monaco.editor.getEditors()[0]?.trigger('teclado', 'type', { text: '// cambio\n' })); | |
| 49 | +await p.waitForTimeout(300); | |
| 50 | +const sucia = await pestana(); | |
| 51 | +ok('2 · con cambios sin guardar, el nombre lo dice', sucia.nombre === 'app.js (cambios sin guardar)', JSON.stringify(sucia)); | |
| 52 | + | |
| 53 | +// 3 · separador del terminal | |
| 54 | +await p.keyboard.press('Control+`'); | |
| 55 | +await p.waitForFunction(() => !document.getElementById('terminal-panel').hidden, null, { timeout: 5000 }).catch(() => {}); | |
| 56 | +await p.waitForTimeout(300); | |
| 57 | +const sep = await p.evaluate(() => { const h = document.getElementById('term-resize'); const panel = document.getElementById('terminal-panel'); | |
| 58 | + return { now: h.getAttribute('aria-valuenow'), min: h.getAttribute('aria-valuemin'), max: h.getAttribute('aria-valuemax'), alto: panel.offsetHeight, ventana: innerHeight }; }); | |
| 59 | +ok('3 · el separador dice su altura al abrir (sin arrastrarlo antes)', sep.now !== null && +sep.now === sep.alto, JSON.stringify(sep)); | |
| 60 | +ok('3 · …y su máximo', sep.max !== null && +sep.max === Math.max(120, sep.ventana - 160) && +sep.max >= +sep.now && +sep.min <= +sep.now, JSON.stringify(sep)); | |
| 61 | +await p.focus('#term-resize'); | |
| 62 | +await p.keyboard.press('ArrowUp'); | |
| 63 | +const tras = await p.evaluate(() => ({ now: +document.getElementById('term-resize').getAttribute('aria-valuenow'), alto: document.getElementById('terminal-panel').offsetHeight })); | |
| 64 | +ok('3 · con ↑ crece y el valor lo sigue', tras.now === tras.alto && tras.now > +sep.now, JSON.stringify(tras)); | |
| 65 | + | |
| 66 | +console.log('\n errores JS:', errs[0] || 'ninguno'); | |
| 67 | +ok('sin errores de página', errs.length === 0, errs.join(' | ')); | |
| 68 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ NOMBRES ACCESIBLES OK — Modos, pestañas y separador'); | |
| 69 | +await b.close(); | |
| 70 | +process.exit(fails ? 1 : 0); |
modified web/js/i18n.js +6 −6
| @@ -140,7 +140,7 @@ | ||
| 140 | 140 | openFailed: "No pude abrir {path}: {e}", |
| 141 | 141 | dirtyTitle: "¿Guardar los cambios de «{name}»?", dirtyBody: "Si no los guardas, se pierden.", |
| 142 | 142 | dirtySave: "Guardar", dirtyDiscard: "No guardar", dirtyCancel: "Cancelar", |
| 143 | - editorTabs: "Ficheros abiertos", closeFile: "Cerrar {name}", closeFileDirty: "Cerrar {name} (cambios sin guardar)", | |
| 143 | + editorTabs: "Ficheros abiertos", closeFile: "Cerrar {name}", closeFileDirty: "Cerrar {name} (cambios sin guardar)", tabUnsaved: "(cambios sin guardar)", | |
| 144 | 144 | fileDeletedDirty: "borrado del disco; guárdalo para recrearlo", |
| 145 | 145 | tmClose: "Cerrar", tmCloseOthers: "Cerrar otras", tmCloseRight: "Cerrar las de la derecha", tmCloseAll: "Cerrar todas", |
| 146 | 146 | tmCopyPath: "Copiar ruta", tmViewSource: "Ver código fuente", tmPreview: "Vista previa", |
| @@ -200,8 +200,8 @@ | ||
| 200 | 200 | // teclado, menús y pestañas |
| 201 | 201 | menubarLabel: "Menú", menu_file: "Archivo", menu_edit: "Editar", menu_view: "Ver", menu_git: "Git", |
| 202 | 202 | gNoRemote: "sin remoto", |
| 203 | - modesLabel: "Modos de trabajo", modesBtn: "Modos", modesNone: "ninguno activo", | |
| 204 | - modeReview: "revisar antes de escribir", modeGoal: "objetivo", modeHard: "Hard Work", | |
| 203 | + modesLabel: "Modos de trabajo", modesBtn: "Modos", | |
| 204 | + modeReview: "revisar antes de escribir", modeAuto: "Auto, escribe sin preguntar", modeGoal: "objetivo", modeHard: "Hard Work", | |
| 205 | 205 | goalPlaceholder: "🎯 Describe el objetivo: lo descompongo en tareas y las hago una a una…", |
| 206 | 206 | convTabs: "Conversaciones abiertas", convBusy: "trabajando", tabCloseNamed: "Cerrar la pestaña «{title}» (no borra la conversación)", |
| 207 | 207 | convRename: "Renombrar…", convRenamePrompt: "Nombre de la conversación (vacío = el automático):", |
| @@ -369,7 +369,7 @@ | ||
| 369 | 369 | openFailed: "Couldn't open {path}: {e}", |
| 370 | 370 | dirtyTitle: "Save the changes to “{name}”?", dirtyBody: "If you don't save them, they are lost.", |
| 371 | 371 | dirtySave: "Save", dirtyDiscard: "Don't save", dirtyCancel: "Cancel", |
| 372 | - editorTabs: "Open files", closeFile: "Close {name}", closeFileDirty: "Close {name} (unsaved changes)", | |
| 372 | + editorTabs: "Open files", closeFile: "Close {name}", closeFileDirty: "Close {name} (unsaved changes)", tabUnsaved: "(unsaved changes)", | |
| 373 | 373 | fileDeletedDirty: "deleted from disk; save it to recreate it", |
| 374 | 374 | tmClose: "Close", tmCloseOthers: "Close others", tmCloseRight: "Close to the right", tmCloseAll: "Close all", |
| 375 | 375 | tmCopyPath: "Copy path", tmViewSource: "View source", tmPreview: "Preview", |
| @@ -429,8 +429,8 @@ | ||
| 429 | 429 | // keyboard, menus and tabs |
| 430 | 430 | menubarLabel: "Menu", menu_file: "File", menu_edit: "Edit", menu_view: "View", menu_git: "Git", |
| 431 | 431 | gNoRemote: "no remote", |
| 432 | - modesLabel: "Work modes", modesBtn: "Modes", modesNone: "none on", | |
| 433 | - modeReview: "review before writing", modeGoal: "goal", modeHard: "Hard Work", | |
| 432 | + modesLabel: "Work modes", modesBtn: "Modes", | |
| 433 | + modeReview: "review before writing", modeAuto: "Auto, writes without asking", modeGoal: "goal", modeHard: "Hard Work", | |
| 434 | 434 | goalPlaceholder: "🎯 Describe the goal: I'll break it into tasks and do them one by one…", |
| 435 | 435 | convTabs: "Open conversations", convBusy: "working", tabCloseNamed: "Close the “{title}” tab (doesn't delete the conversation)", |
| 436 | 436 | convRename: "Rename…", convRenamePrompt: "Conversation name (empty = automatic):", |
modified web/js/ide.js +3 −0
| @@ -361,6 +361,9 @@ | ||
| 361 | 361 | // <div> sin foco. La activa entra con Tab; ←/→ se mueven entre ellas. |
| 362 | 362 | el.setAttribute('role', 'tab'); |
| 363 | 363 | el.setAttribute('aria-selected', on ? 'true' : 'false'); |
| 364 | + // Nombre propio: sin él, el de la pestaña era el fichero MÁS el botón × que | |
| 365 | + // lleva dentro («app.js Cerrar app.js»). | |
| 366 | + el.setAttribute('aria-label', baseOf(tb.path) + (tb.dirty ? ' ' + t('tabUnsaved') : '') + (tb.deleted ? ' — ' + t('fileDeletedDirty') : '')); | |
| 364 | 367 | el.tabIndex = on ? 0 : -1; |
| 365 | 368 | const ico = document.createElement('span'); |
| 366 | 369 | ico.className = 'tab-ico'; |
modified web/js/main.js +19 −2
| @@ -1900,8 +1900,13 @@ | ||
| 1900 | 1900 | pintaCapacidades(); |
| 1901 | 1901 | await terminal.mount($('terminal-host')); |
| 1902 | 1902 | terminal.refit(); |
| 1903 | + pintaSeparadorTerminal(); | |
| 1903 | 1904 | } |
| 1904 | 1905 | } |
| 1906 | +// El separador que cambia la altura del terminal dice su valor y su rango | |
| 1907 | +// desde que se abre (antes aria-valuenow no existía hasta el primer arrastre, y | |
| 1908 | +// aria-valuemax nunca). Lo pone en marcha el bloque del separador, más abajo. | |
| 1909 | +let pintaSeparadorTerminal = () => {}; | |
| 1905 | 1910 | // La etiqueta del terminal sigue al bridge: antes solo se pintaba al abrir el |
| 1906 | 1911 | // panel y se quedaba vieja si el bridge conectaba o caía con él abierto. |
| 1907 | 1912 | function pintaCapacidades() { |
| @@ -1921,12 +1926,20 @@ | ||
| 1921 | 1926 | const panel = $('terminal-panel'), handle = $('term-resize'); |
| 1922 | 1927 | let sy = 0, sh = 0; |
| 1923 | 1928 | // También con el teclado: es un separador con foco, ↑/↓ cambian la altura. |
| 1929 | + const maxAlto = () => Math.max(120, window.innerHeight - 160); | |
| 1924 | 1930 | const ajusta = h => { |
| 1925 | - h = Math.max(120, Math.min(window.innerHeight - 160, h)); | |
| 1931 | + h = Math.max(120, Math.min(maxAlto(), h)); | |
| 1926 | 1932 | panel.style.height = h + 'px'; |
| 1927 | 1933 | handle.setAttribute('aria-valuenow', String(Math.round(h))); |
| 1934 | + handle.setAttribute('aria-valuemax', String(maxAlto())); | |
| 1928 | 1935 | terminal.refit(); |
| 1929 | 1936 | }; |
| 1937 | + pintaSeparadorTerminal = () => { | |
| 1938 | + handle.setAttribute('aria-valuemax', String(maxAlto())); | |
| 1939 | + if (!panel.hidden && panel.offsetHeight) handle.setAttribute('aria-valuenow', String(Math.round(panel.offsetHeight))); | |
| 1940 | + }; | |
| 1941 | + pintaSeparadorTerminal(); | |
| 1942 | + window.addEventListener('resize', () => pintaSeparadorTerminal()); | |
| 1930 | 1943 | handle.setAttribute('role', 'separator'); |
| 1931 | 1944 | handle.setAttribute('aria-orientation', 'horizontal'); |
| 1932 | 1945 | handle.setAttribute('aria-label', t('termResizeLabel')); |
| @@ -2299,7 +2312,11 @@ | ||
| 2299 | 2312 | if (goalMode) activos.push(['🎯', t('modeGoal')]); |
| 2300 | 2313 | if (hardMode) activos.push(['⛏', t('modeHard')]); |
| 2301 | 2314 | b.textContent = '⚙︎ ' + t('modesBtn') + (activos.length ? ' · ' + activos.map(a => a[0] === 'Revisar' ? t('reviewTxt') : a[0]).join(' ') : '') + ' ▾'; |
| 2302 | - b.setAttribute('aria-label', t('modesBtn') + (activos.length ? ': ' + activos.map(a => a[1]).join(', ') : ': ' + t('modesNone'))); | |
| 2315 | + // El nombre accesible dice TODOS los modos encendidos, también Auto, que es el | |
| 2316 | + // de por defecto: con Auto encendido decía «Modos: ninguno activo» mientras el | |
| 2317 | + // menú lo mostraba marcado. | |
| 2318 | + const nombres = [autoEdit ? t('modeAuto') : t('modeReview'), ...activos.filter(a => a[0] !== 'Revisar').map(a => a[1])]; | |
| 2319 | + b.setAttribute('aria-label', t('modesBtn') + ': ' + nombres.join(', ')); | |
| 2303 | 2320 | b.classList.toggle('on', activos.length > 0); |
| 2304 | 2321 | $('btn-autoedit')?.setAttribute('aria-checked', autoEdit ? 'true' : 'false'); |
| 2305 | 2322 | $('btn-goal')?.setAttribute('aria-checked', goalMode ? 'true' : 'false'); |