test: Klicktests browser2chat.5 bis .8 (Chat-Kopf, Seitenleiste, Konfiguration je Antwort, Player beim Scrollen) und Skripte
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg6sxZ8wsKZAVLQ6Xj5
This commit is contained in:
@ -17,5 +17,9 @@ eingebauten WebSocket von Node (kein Paket, keine Installation). Sie laufen gege
|
||||
| `vorlesen-ohne-studio.mjs` | Stimme freigeben (24 parallele Abrufe), Vorlesen bei ausgefallenem Studio (Fehlerblase mit Text) | `browser2stimmen.6`, `browser2vorlesen.3` |
|
||||
| `enginefenster.mjs` | Fenster-Symbole der Engines-Seite (gestrichelt ohne Link, Klick ohne Wirkung) | `admin2enginefenster.3` |
|
||||
| `strom-ohne-ton.mjs` | Playground „Vorlesen“, wenn das Studio einen Strom ohne Ton liefert (Weiterleitung zum Studio nötig) | `client2sprachausgabe.10` |
|
||||
| `chat-layout.mjs` | Chat-Kopf (Persona, Stimme), Seitenleiste (Suche, Anheften, Löschen, Ein/Aus), Konfiguration je Antwort, Kopieren/Wiederholen, Modellwechsel | `browser2chat.5` bis `.7` |
|
||||
| `chat-player-scroll.mjs` | Mini-Player bleibt beim Scrollen des Verlaufs an seiner Stelle | `browser2chat.8` |
|
||||
| `chat-player.mjs` | Mini-Player: Zeit, Gesamtdauer, Balken, Stopp | `browser2chat.4` |
|
||||
| `chat-umbenennen.mjs`, `chat-denkstufe.mjs` | Chat umbenennen; Denkstufe nur bei bestätigtem Test | `browser2chat.2`, `.3` |
|
||||
|
||||
`lib.mjs` ist der kleine Treiber. Die Skripte sind Prüfwerkzeuge, kein Teil des Programms.
|
||||
|
||||
94
scripts/ui-pruefung/chat-layout.mjs
Normal file
94
scripts/ui-pruefung/chat-layout.mjs
Normal file
@ -0,0 +1,94 @@
|
||||
// CHAT-01 bis CHAT-05 (Vorlage v1.2): browser2chat.5 (Kopf), .6 (Seitenleiste), .7 (Konfiguration je Antwort, Kopieren/Wiederholen)
|
||||
// (.8 Player beim Scrollen: chat-player-scroll.mjs). Aufruf: node chat-layout.mjs <Passwort>
|
||||
// Testinstanz mit den Modellen „chat“ und „chat2“ (fake_llama_lang.py) und tts-base hinter der Studio-Weiterleitung (Datei „pcm“).
|
||||
import * as cdp from './lib.mjs';
|
||||
const BASE=process.env.NEXUS_BASE||'http://127.0.0.1:18122', pw=process.argv[2];
|
||||
const b=await cdp.start({port:9375,args:['--autoplay-policy=no-user-gesture-required']});
|
||||
const ok=(n,c,d='')=>{console.log(`${c?'ok ':'FEHLER'} ${n}${d?' – '+d:''}`); if(!c) process.exitCode=1;};
|
||||
const warte=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
const ev=x=>b.eval(x);
|
||||
const listeTitel=()=>ev(`[...document.querySelectorAll('#chat-liste li .titel')].map(x=>x.textContent)`);
|
||||
const frage=async t=>{ await ev(`document.getElementById('chat-text').value=${JSON.stringify(t)}`); await ev(`document.getElementById('chat-senden').click()`);
|
||||
const n0=await ev(`document.querySelectorAll('.blase.assistant').length`);
|
||||
for(let i=0;i<300;i++){ await warte(400); if(await ev(`!document.getElementById('chat-senden').disabled && document.querySelectorAll('.blase.assistant').length>${n0}`)) break; } await warte(1200); };
|
||||
const waehle=async(id,v)=>{ await ev(`(()=>{const s=document.getElementById('${id}'); s.value=${JSON.stringify(v)}; s.dispatchEvent(new Event('change',{bubbles:true}));})()`); await warte(300); };
|
||||
const klick=t=>ev(`(()=>{const k=[...document.querySelectorAll('button')].find(x=>x.textContent.trim()===${JSON.stringify(t)}); if(!k) return false; k.click(); return true;})()`);
|
||||
try{
|
||||
await b.login(BASE,'claude',pw);
|
||||
// Personas anlegen (nur wenn nötig)
|
||||
await b.goto(BASE+'/ui/personas'); await warte(800);
|
||||
if(!/Luna/.test(await ev('document.body.innerText'))){
|
||||
for(const [n,stil] of [['Luna','Freundlich und kurz.'],['Karl','Sachlich.']]){
|
||||
await ev(`(async()=>{const csrf=document.body.getAttribute('data-csrf'); const d=new URLSearchParams({csrf,id:'',name:${JSON.stringify(n)},systemprompt:'Du bist '+${JSON.stringify(n)}+'.',stil:${JSON.stringify(stil)},stimme:''}); await fetch('/ui/personas/speichern',{method:'POST',headers:{'content-type':'application/x-www-form-urlencoded'},body:d});})()`); await warte(500);
|
||||
}
|
||||
}
|
||||
await b.goto(BASE+'/ui/chat'); await warte(1200);
|
||||
await ev(`document.getElementById('chat-max').value='30'`);
|
||||
await waehle('chat-sprache','tts-base'); await warte(1200);
|
||||
await ev(`(()=>{const s=document.getElementById('chat-stimme'); const o=[...s.options].find(o=>/Scotty/.test(o.textContent)); if(o){s.value=o.value; s.dispatchEvent(new Event('change',{bubbles:true}));}})()`);
|
||||
|
||||
// ---- .5 Kopf
|
||||
const kopf=await ev(`(()=>{const k=document.getElementById('chat-kopf'), v=document.getElementById('chat-verlauf'); const pers=document.getElementById('chat-persona'); return {persona:[...pers.options].map(o=>o.textContent.trim()), kopfOben:k.getBoundingClientRect().bottom<=v.getBoundingClientRect().top+1, personaImKopf:k.contains(pers), stimmeImKopf:k.contains(document.getElementById('chat-stimmen-popover')), detailsOffen:document.getElementById('chat-persona-popover').open, stimmeOffen:document.getElementById('chat-stimmen-popover').open};})()`);
|
||||
ok('.5 Kopf: Persona-Auswahl (aus, Luna, Karl) und Stimme im Kopf, oberhalb des Verlaufs', kopf.personaImKopf&&kopf.stimmeImKopf&&kopf.kopfOben&&['aus','Luna','Karl'].every(n=>kopf.persona.includes(n)), JSON.stringify(kopf));
|
||||
ok('.5 Popover sind zunächst zu', !kopf.detailsOffen && !kopf.stimmeOffen);
|
||||
const lunaWert=await ev(`[...document.getElementById('chat-persona').options].find(o=>o.textContent.trim()==='Luna').value`);
|
||||
await waehle('chat-persona',lunaWert);
|
||||
await ev(`document.getElementById('chat-persona-popover').open=true`); await warte(200);
|
||||
const det=await ev(`document.getElementById('chat-persona-details').textContent`);
|
||||
ok('.5 Detail-Popover nennt Name, Version, Stimme, Umfang (ohne Prompt-Text)', /Luna · Version 1 · Stimme: .* · Umfang/.test(det) && !/Du bist Luna/.test(det), det);
|
||||
await ev(`document.getElementById('chat-stimmen-popover').open=true`); await warte(200);
|
||||
const st=await ev(`(()=>{const p=document.getElementById('chat-stimmen-popover'); return {select:!!p.querySelector('#chat-stimme'), vorschau:!!p.querySelector('#chat-stimme-vorschau'), sichtbar:p.querySelector('#chat-stimme').getBoundingClientRect().width>0, optionen:[...p.querySelectorAll('#chat-stimme option')].map(o=>o.textContent.trim())};})()`);
|
||||
ok('.5 Stimmen-Popover: Auswahl und Vorschau-Knopf, Stimmen aus dem Studio', st.select&&st.vorschau&&st.sichtbar&&st.optionen.some(o=>/Scotty/.test(o)), JSON.stringify(st));
|
||||
|
||||
// ---- .7 Konfiguration je Antwort (mit Luna), danach Persona wechseln
|
||||
await frage('Erste Frage');
|
||||
await waehle('chat-persona',await ev(`[...document.getElementById('chat-persona').options].find(o=>o.textContent.trim()==='Karl').value`));
|
||||
await frage('Zweite Frage');
|
||||
const metas=()=>ev(`[...document.querySelectorAll('.blase.assistant')].map(x=>(x.querySelector('.meta')||{}).textContent||'')`);
|
||||
let m=await metas();
|
||||
ok('.7 Erste Antwort nennt Persona Luna (Version 1), zweite Karl, trotz Wechsel', /Persona Luna · Version 1/.test(m[0]) && /Persona Karl · Version 1/.test(m[1]), JSON.stringify(m));
|
||||
const aktionen=await ev(`[...document.querySelectorAll('.blase.assistant')].map(x=>[...x.querySelectorAll('button')].map(k=>k.textContent.trim()).join(','))`);
|
||||
ok('.7 Kopieren und Vorlesen unter jeder Antwort, Wiederholen nur an der letzten', /Kopieren/.test(aktionen[0])&&/Vorlesen/.test(aktionen[0])&&!/Wiederholen/.test(aktionen[0])&&/Kopieren/.test(aktionen[1])&&/Wiederholen/.test(aktionen[1]), JSON.stringify(aktionen));
|
||||
const n1=await ev(`document.querySelectorAll('.blase.assistant').length`);
|
||||
await ev(`[...document.querySelectorAll('.blase.assistant')].pop().querySelectorAll('button').forEach(k=>{if(k.textContent.trim()==='Wiederholen') k.click();})`);
|
||||
for(let i=0;i<300;i++){ await warte(400); if(await ev(`!document.getElementById('chat-senden').disabled`)) break; } await warte(1200);
|
||||
ok('.7 Wiederholen ersetzt die letzte Antwort (gleiche Anzahl)', (await ev(`document.querySelectorAll('.blase.assistant').length`))===n1);
|
||||
// Modellwechsel: kein neuer Chat
|
||||
const vorher=(await listeTitel()).length;
|
||||
await waehle('chat-modell','chat2'); await frage('Dritte Frage mit anderem Modell');
|
||||
m=await metas();
|
||||
ok('.6 Modellwechsel erzeugt keinen neuen Chat, die Konfiguration wird je Antwort festgehalten', (await listeTitel()).length===vorher && /Modell chat2/.test(m[m.length-1]) && /Modell chat /.test(m[0]), `Chats ${vorher}→${(await listeTitel()).length}; ${JSON.stringify(m.map(x=>x.slice(0,30)))}`);
|
||||
// nach Neuladen und Öffnen aus der Liste: Konfiguration bleibt
|
||||
await warte(1500); await b.goto(BASE+'/ui/chat'); await warte(1500);
|
||||
await ev(`document.querySelector('#chat-liste li .titel').click()`); await warte(800);
|
||||
m=await metas();
|
||||
ok('.7 Nach Neuladen und Öffnen aus dem Verlauf stehen die Angaben je Antwort noch da', m.length>=3 && /Persona Luna/.test(m[0]) && /Persona Karl/.test(m[1]) && /Modell chat2/.test(m[m.length-1]), JSON.stringify(m.map(x=>x.slice(0,40))));
|
||||
|
||||
// ---- .6 Seitenleiste
|
||||
await ev(`document.getElementById('chat-neu').click()`); await warte(500);
|
||||
await ev(`document.getElementById('chat-max').value='30'`); await waehle('chat-modell','chat');
|
||||
await frage('Anderes Thema Bananen');
|
||||
let t=await listeTitel();
|
||||
ok('.6 Zwei Chats in der Liste, der neue zuerst', t.length===2 && /Bananen/.test(t[0]), JSON.stringify(t));
|
||||
await ev(`(()=>{const s=document.getElementById('chat-suche'); s.value='erste'; s.dispatchEvent(new Event('input',{bubbles:true}));})()`); await warte(400);
|
||||
t=await listeTitel(); ok('.6 Suche findet nach Titel und Inhalt', t.length===1 && /Erste/.test(t[0]), JSON.stringify(t));
|
||||
await ev(`(()=>{const s=document.getElementById('chat-suche'); s.value='ananas'; s.dispatchEvent(new Event('input',{bubbles:true}));})()`); await warte(400);
|
||||
t=await listeTitel(); ok('.6 Suche ohne Treffer meldet „Keine Treffer“', t.length===0 && /Keine Treffer/.test(await ev(`document.getElementById('chat-liste').textContent`)));
|
||||
await ev(`(()=>{const s=document.getElementById('chat-suche'); s.value=''; s.dispatchEvent(new Event('input',{bubbles:true}));})()`); await warte(400);
|
||||
// Anheften: den älteren (zweiter Eintrag) anheften
|
||||
await ev(`[...document.querySelectorAll('#chat-liste li')][1].querySelectorAll('button').forEach(k=>{if(k.textContent.trim()==='Anheften') k.click();})`); await warte(600);
|
||||
t=await listeTitel(); const pin=await ev(`[...document.querySelectorAll('#chat-liste li')][0].querySelector('[aria-pressed]').getAttribute('aria-pressed')`);
|
||||
ok('.6 Angehefteter Chat steht oben (aria-pressed=true, Knopf „Lösen“)', /Erste/.test(t[0]) && pin==='true', JSON.stringify(t)+pin);
|
||||
await ev(`document.getElementById('chat-seite-knopf').click()`); await warte(300);
|
||||
const zu=await ev(`(()=>{const a=document.querySelector('.chat-seite'); return {exp:document.getElementById('chat-seite-knopf').getAttribute('aria-expanded'), breite:Math.round(a.getBoundingClientRect().width)};})()`);
|
||||
ok('.6 „Verlauf ein/aus“ klappt die Leiste ein (aria-expanded=false)', zu.exp==='false' && zu.breite<=1, JSON.stringify(zu));
|
||||
await ev(`document.getElementById('chat-seite-knopf').click()`); await warte(300);
|
||||
// Löschen mit Rückfrage
|
||||
await ev(`[...document.querySelectorAll('#chat-liste li')][1].querySelectorAll('button').forEach(k=>{if(k.textContent.trim()==='Löschen') k.click();})`); await warte(300);
|
||||
const rueck=await ev(`[...document.querySelectorAll('#chat-liste li')][1].textContent`);
|
||||
ok('.6 Löschen fragt erst nach („Wirklich löschen?“), danach noch zwei Chats', /Wirklich löschen\?/.test(rueck) && (await listeTitel()).length===2);
|
||||
await ev(`[...document.querySelectorAll('#chat-liste li')][1].querySelectorAll('button').forEach(k=>{if(/Wirklich/.test(k.textContent)) k.click();})`); await warte(1000);
|
||||
ok('.6 Zweiter Klick löscht (ein Chat bleibt)', (await listeTitel()).length===1);
|
||||
|
||||
await b.shot('/tmp/chat-layout.png');
|
||||
}catch(e){console.log('Fehler im Lauf:',e.message); process.exitCode=1;} finally{b.close();}
|
||||
24
scripts/ui-pruefung/chat-player-scroll.mjs
Normal file
24
scripts/ui-pruefung/chat-player-scroll.mjs
Normal file
@ -0,0 +1,24 @@
|
||||
// browser2chat.8 (CHAT-04, Vorlage v1.2): Der Mini-Player bleibt beim Scrollen des Verlaufs erreichbar (feste Stelle, im Fenster).
|
||||
// Aufruf: node chat-player-scroll.mjs <Passwort> (Testinstanz wie chat-layout.mjs; die Antwort der Attrappe ist lang)
|
||||
import * as cdp from './lib.mjs';
|
||||
const BASE=process.env.NEXUS_BASE||'http://127.0.0.1:18122', pw=process.argv[2];
|
||||
const b=await cdp.start({port:9376,args:['--autoplay-policy=no-user-gesture-required']});
|
||||
const ok=(n,c,d='')=>{console.log(`${c?'ok ':'FEHLER'} ${n}${d?' – '+d:''}`); if(!c) process.exitCode=1;};
|
||||
const warte=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
const ev=x=>b.eval(x);
|
||||
try{
|
||||
await b.login(BASE,'claude',pw);
|
||||
await b.viewport(1100,700,{mobile:false});
|
||||
await b.goto(BASE+'/ui/chat'); await warte(1200);
|
||||
await ev(`(()=>{const s=document.getElementById('chat-sprache'); s.value='tts-base'; s.dispatchEvent(new Event('change',{bubbles:true}));})()`); await warte(800);
|
||||
await ev(`document.getElementById('chat-max').value='400'`);
|
||||
await ev(`document.getElementById('chat-text').value='Lange Antwort bitte'`); await ev(`document.getElementById('chat-senden').click()`);
|
||||
for(let i=0;i<300;i++){ await warte(500); if(await ev(`!document.getElementById('chat-senden').disabled && document.querySelectorAll('.blase.assistant').length>0`)) break; } await warte(1200);
|
||||
const pos=()=>ev(`(()=>{const p=document.getElementById('chat-player').getBoundingClientRect(); const v=document.getElementById('chat-verlauf'); return {oben:Math.round(p.top), unten:Math.round(p.bottom), innen:p.top>=0&&p.bottom<=window.innerHeight, scrollbar:v.scrollHeight>v.clientHeight, scrollTop:Math.round(v.scrollTop)};})()`);
|
||||
const unten=await pos();
|
||||
await ev(`document.getElementById('chat-verlauf').scrollTop=0`); await warte(400);
|
||||
const oben=await pos();
|
||||
ok('Der Verlauf ist länger als sein Fenster (es wird wirklich gescrollt)', unten.scrollbar && unten.scrollTop>oben.scrollTop, JSON.stringify([unten,oben]));
|
||||
ok('Player bleibt beim Scrollen an derselben Stelle und im Fenster', oben.innen && unten.oben===oben.oben, JSON.stringify([unten.oben,oben.oben]));
|
||||
await b.shot('/tmp/chat-player-scroll.png');
|
||||
}catch(e){console.log('Fehler im Lauf:',e.message); process.exitCode=1;} finally{b.close();}
|
||||
Reference in New Issue
Block a user