// Befunde der Oberflächenprüfung vor 1.0.0 (#1284) in einem echten Chromium nachprüfen: Dialog, Aktionsspalte, // Modellsuche, Leerzustand und Tastatur im Protokoll, Ausfallhinweis. Testinstanz mit mindestens einem Modell mit // Bearbeiten-Dialog und llama.cpp mit model_roots; Aufruf: NEXUS_BASE=… node befunde-1284.mjs import { start } from './lib.mjs'; const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112'; const warte = ms => new Promise(r => setTimeout(r, ms)); const b = await start({ port: 9488 }); await b.login(BASE, process.env.NEXUS_USER || 'claude', process.argv[2]); b.vp = async (w, thema) => { await b.viewport(w, w < 700 ? 844 : 900, { mobile: w < 700 }); await b.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: thema }] }); }; b.seitlich = () => b.eval('document.documentElement.scrollWidth - document.documentElement.clientWidth'); b.text = (n = 1500) => b.eval(`(document.querySelector('main')||document.body).innerText.slice(0,${n})`); b.key = async (key, code, vk) => { for (const type of ['keyDown', 'keyUp']) await b.send('Input.dispatchKeyEvent', { type, key, code, windowsVirtualKeyCode: vk }); await warte(80); }; let fehler = 0; const ok = (name, bed, info='') => { if (!bed) { fehler++; } console.log((bed?'ok ':'FEHLER ') + name + (info?' ['+info+']':'')); }; const maus = async (x,y) => { for (const type of ['mousePressed','mouseReleased']) await b.send('Input.dispatchMouseEvent',{type,x,y,button:'left',clickCount:1}); await warte(250); }; try { await b.vp(1280,'dark'); await b.goto(BASE+'/ui/modelle'); const knopf = await b.eval(`[...document.querySelectorAll('[data-dialog^="dlg-"]')].map(e=>e.getAttribute('data-dialog')).find(i=>document.getElementById(i)?.querySelector('input,select'))`); await b.eval(`document.querySelector('[data-dialog="${knopf}"]').click()`); await warte(300); const r = await b.eval(`(()=>{const r=document.getElementById('${knopf}').getBoundingClientRect();return [r.left,r.top,r.right,r.bottom]})()`); const offen = () => b.eval(`document.getElementById('${knopf}').open`); await maus(r[0]+4, r[1]+4); ok('U2 Klick in den Innenrand lässt den Dialog offen', await offen()); await maus(r[0]+4, (r[1]+r[3])/2); ok('U2 Klick in eine Lücke am Rand lässt ihn offen', await offen()); await maus(Math.max(2, r[0]-30), r[1]+10); ok('U2 Klick auf den Hintergrund schließt', !(await offen()), JSON.stringify(r.map(Math.round))); await b.vp(390,'dark'); await b.goto(BASE+'/ui/modelle'); ok('U3 Aktionsspalte klebt am Handy nicht', (await b.eval(`getComputedStyle(document.querySelector('td.aktionen')).position`))==='static'); await b.vp(1280,'dark'); await b.goto(BASE+'/ui/modelle'); ok('U3 am breiten Schirm klebt sie weiter', (await b.eval(`getComputedStyle(document.querySelector('td.aktionen')).position`))==='sticky'); await b.vp(390,'dark'); await b.goto(BASE+'/ui/engines?suche=llama.cpp'); await warte(800); ok('U5 Modellsuche ohne seitliches Scrollen der Seite', (await b.seitlich())<=1 && await b.eval(`!!document.querySelector('.engine-suche table')`), 'ueberlauf '+await b.seitlich()); await b.vp(1280,'dark'); await b.goto(BASE+'/ui/protokoll?reiter=anfragen&q=gibtsnichtxyz'); ok('U6 Leerzustand', (await b.text(2000)).includes('Keine Einträge für diese Auswahl')); await b.goto(BASE+'/ui/protokoll?reiter=anfragen'); await b.eval(`document.querySelector('form[data-auto] select[name=zeit]').focus()`); const wert = () => b.eval(`document.querySelector('select[name=zeit]').value`); const vor = await wert(); await b.key('ArrowDown','ArrowDown',40); await warte(300); await b.key('ArrowDown','ArrowDown',40); await warte(300); const mitte = await wert(); const url1 = await b.eval('location.search'); await warte(2800); const url2 = await b.eval('location.search'); const fokus = await b.eval('document.activeElement.name||document.activeElement.tagName'); ok('U7 zwei Pfeiltasten ohne Neuladen dazwischen', mitte!==vor && !url1.includes('zeit=') , vor+' -> '+mitte+' '+url1); ok('U7 nach der Pause geladen, Fokus auf der Auswahl', url2.includes('zeit='+mitte) && fokus==='zeit', url2+' fokus '+fokus); await b.goto(BASE+'/ui/modelle'); await b.eval(`window.fetch = () => Promise.reject(new Error('aus'))`); await warte(11000); ok('U4 Modellseite meldet den Ausfall', (await b.eval(`document.getElementById('mod-stand').textContent`)).length>0, await b.eval(`document.getElementById('mod-stand').textContent`)); } catch (e) { fehler++; console.log('Abbruch', e.message); } finally { b.close(); } process.exit(fehler ? 1 : 0);