30 lines
2.4 KiB
JavaScript
30 lines
2.4 KiB
JavaScript
import { start } from './lib.mjs';
|
|
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112';
|
|
const S = process.argv[2]; const pw = process.argv[3]; const tag = process.argv[4] || 'vorher';
|
|
const b = await start();
|
|
const senden = txt => `(() => { const ta = document.querySelector('#chat textarea'); ta.value = ${JSON.stringify(txt)}; document.querySelector('#chat button[type=submit]').click(); return 1; })()`;
|
|
const mess = `(() => { const v = document.getElementById('chat-verlauf'); const sel = getSelection(); return JSON.stringify({scrollTop: Math.round(v.scrollTop), max: Math.round(v.scrollHeight - v.clientHeight), amEnde: Math.round(v.scrollHeight - v.clientHeight - v.scrollTop) < 5, markiert: sel.toString().length, bubbles: v.querySelectorAll('.blase').length, button: !!Array.from(document.querySelectorAll('#chat button')).find(x => /aktuell/i.test(x.textContent) && x.offsetParent !== null)}); })()`;
|
|
try {
|
|
await b.login(BASE, 'claude', pw);
|
|
await b.viewport(1100, 700, { dsf: 1, mobile: false });
|
|
await b.goto(BASE + '/ui/chat');
|
|
await b.eval(senden('Erste Frage'));
|
|
await new Promise(r => setTimeout(r, 38000));
|
|
console.log('nach Antwort 1:', await b.eval(mess));
|
|
await b.eval(senden('Zweite Frage'));
|
|
await new Promise(r => setTimeout(r, 6000));
|
|
console.log('Antwort 2 streamt (6 s), am Ende:', await b.eval(mess));
|
|
// bewusst nach oben scrollen und Text der ersten Antwort markieren
|
|
await b.eval(`(() => { const v = document.getElementById('chat-verlauf'); v.scrollTop = 0; const a = v.querySelector('.blase.assistant span'); const r = document.createRange(); r.setStart(a.firstChild, 0); r.setEnd(a.firstChild, 30); const s = getSelection(); s.removeAllRanges(); s.addRange(r); return 1; })()`);
|
|
console.log('nach Hochscrollen + Markieren:', await b.eval(mess));
|
|
await new Promise(r => setTimeout(r, 6000));
|
|
console.log('6 s später (Streaming läuft):', await b.eval(mess));
|
|
await b.shot(`${S}/cdp/stream-${tag}.png`);
|
|
// Rücksprung per Knopf, danach folgt die Ansicht wieder
|
|
await b.eval(`(() => { const k = Array.from(document.querySelectorAll('#chat button')).find(x => /aktuell/i.test(x.textContent)); if (k) k.click(); return 1; })()`);
|
|
await new Promise(r => setTimeout(r, 3000));
|
|
console.log('nach Klick auf den Rücksprung-Knopf, 3 s später:', await b.eval(mess));
|
|
await new Promise(r => setTimeout(r, 18000));
|
|
console.log('nach Ende des Streams:', await b.eval(mess));
|
|
} finally { b.close(); }
|