fix: Kontrast im hellen Theme (Text und Hauptknöpfe mit --accent-strong, Fokusring); Prüfskripte für die Oberfläche (#1174)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
16
scripts/ui-pruefung/README.md
Normal file
16
scripts/ui-pruefung/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Prüfskripte für die Oberfläche (Chromium über das DevTools-Protokoll)
|
||||
|
||||
Diese Skripte starten ein eigenes Chromium (`/usr/bin/chromium`, headless, eigenes Profil) und steuern es mit dem
|
||||
eingebauten WebSocket von Node (kein Paket, keine Installation). Sie laufen gegen eine **Testinstanz** (Standard
|
||||
`http://127.0.0.1:18112`, überschreibbar mit `NEXUS_BASE`) und melden sich mit einem Testbenutzer an
|
||||
(Aufruf: `node skript.mjs <Testpasswort> [...]`, Benutzername `claude`). Gegen die Produktion nicht verwenden.
|
||||
|
||||
| Skript | Prüft | Test |
|
||||
| --- | --- | --- |
|
||||
| `ueberlagerung.mjs` | Chat bei 390×844, 320×568, Querformat, Tastatur-Höhen, 200 % Zoom, Seitenleiste an/aus: Ist jedes Bedienelement erreichbar (nichts liegt darüber), liegt der Hinweis unter der Karte | `browser2bedienung.1` |
|
||||
| `streaming-scroll.mjs` | Beim Streaming nicht weggescrollt werden, Markierung bleibt, Rücksprung-Knopf (braucht `fake_llama_lang.py` als `llama_cpp.binary`) | `browser2bedienung.2` |
|
||||
| `fokus-aktualisierung.mjs`, `fokus-aktualisierung-knopf.mjs` | Fokus und Cursor bei der Aktualisierung der Modellseite (zweites Modell `zweit` nötig) | `browser2bedienung.3` |
|
||||
| `kontrast.mjs` | Textkontrast aller sichtbaren Texte auf allen Seiten, hell und dunkel, Verläufe einzeln (Grenze 4,5:1, großer Text 3:1) | `browser2bedienung.4` |
|
||||
| `fokusring.mjs` | Fokusring von Knopf, Link, Feld und Auswahl in beiden Themes | `browser2bedienung.4` |
|
||||
|
||||
`lib.mjs` ist der kleine Treiber. Die Skripte sind Prüfwerkzeuge, kein Teil des Programms.
|
||||
107
scripts/ui-pruefung/fake_llama_lang.py
Executable file
107
scripts/ui-pruefung/fake_llama_lang.py
Executable file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Attrappe für llama-server, nur für Tests von nexus-adapter.
|
||||
|
||||
Versteht die Argumente, die der Adapter übergibt (-m, --host, --port, ...),
|
||||
und verhält sich nach FAKE_LLAMA_MODE:
|
||||
ok antwortet auf /health zuerst mit 503, nach FAKE_LLAMA_LOAD_SECONDS mit 200
|
||||
crash schreibt einen Fehler nach stderr und endet mit Exit-Code 3
|
||||
hang wird nie bereit (immer 503)
|
||||
stubborn wie ok, ignoriert aber SIGTERM (zwingt den Adapter zum harten Beenden)
|
||||
|
||||
Antwortet außerdem auf GET /v1/models und POST /v1/chat/completions (mit und
|
||||
ohne SSE-Streaming) im OpenAI-Format, damit SDK-Tests das Gateway prüfen können.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
|
||||
def opt(name):
|
||||
return args[args.index(name) + 1] if name in args else None
|
||||
|
||||
|
||||
mode = os.environ.get("FAKE_LLAMA_MODE", "ok")
|
||||
print("fake-llama: pid", os.getpid(), flush=True)
|
||||
print("fake-llama: args", " ".join(args), flush=True)
|
||||
print("fake-llama: CUDA_VISIBLE_DEVICES=" + os.environ.get("CUDA_VISIBLE_DEVICES", "<unset>"), flush=True)
|
||||
|
||||
if mode == "crash":
|
||||
print("fake-llama: error: failed to load model", file=sys.stderr, flush=True)
|
||||
sys.exit(3)
|
||||
|
||||
if mode == "stubborn":
|
||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||
else:
|
||||
signal.signal(signal.SIGTERM, lambda *_: os._exit(0))
|
||||
|
||||
started = time.time()
|
||||
load_seconds = float(os.environ.get("FAKE_LLAMA_LOAD_SECONDS", "1"))
|
||||
|
||||
|
||||
ANSWER = []
|
||||
for i in range(1, 401):
|
||||
ANSWER.append(("Wort%d" % i) + (chr(10) if i % 8 == 0 else " "))
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self, *_):
|
||||
pass
|
||||
|
||||
def _send_json(self, code, payload):
|
||||
body = json.dumps(payload).encode()
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == "/health":
|
||||
ready = mode in ("ok", "stubborn") and time.time() - started >= load_seconds
|
||||
if ready:
|
||||
self._send_json(200, {"status": "ok"})
|
||||
else:
|
||||
self._send_json(503, {"error": {"message": "Loading model"}})
|
||||
elif self.path == "/v1/models":
|
||||
alias = opt("--alias") or "modell"
|
||||
self._send_json(200, {"object": "list", "data": [{"id": alias, "object": "model", "created": 0, "owned_by": "fake"}]})
|
||||
else:
|
||||
self._send_json(404, {})
|
||||
|
||||
def do_POST(self):
|
||||
length = int(self.headers.get("Content-Length", "0"))
|
||||
request = json.loads(self.rfile.read(length) or b"{}")
|
||||
if self.path != "/v1/chat/completions":
|
||||
self._send_json(404, {})
|
||||
return
|
||||
model = request.get("model", "modell")
|
||||
if request.get("stream"):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/event-stream")
|
||||
self.send_header("Cache-Control", "no-cache")
|
||||
self.end_headers()
|
||||
for i, part in enumerate(ANSWER):
|
||||
chunk = {"id": "chatcmpl-fake", "object": "chat.completion.chunk", "created": 1, "model": model,
|
||||
"choices": [{"index": 0, "delta": {"role": "assistant", "content": part} if i == 0 else {"content": part}, "finish_reason": None}]}
|
||||
self.wfile.write(("data: " + json.dumps(chunk) + "\n\n").encode())
|
||||
self.wfile.flush()
|
||||
time.sleep(0.08)
|
||||
last = {"id": "chatcmpl-fake", "object": "chat.completion.chunk", "created": 1, "model": model,
|
||||
"choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}]}
|
||||
self.wfile.write(("data: " + json.dumps(last) + "\n\ndata: [DONE]\n\n").encode())
|
||||
self.wfile.flush()
|
||||
else:
|
||||
self._send_json(200, {
|
||||
"id": "chatcmpl-fake", "object": "chat.completion", "created": 1, "model": model,
|
||||
"choices": [{"index": 0, "finish_reason": "stop",
|
||||
"message": {"role": "assistant", "content": "".join(ANSWER)}}],
|
||||
"usage": {"prompt_tokens": 3, "completion_tokens": 4, "total_tokens": 7},
|
||||
})
|
||||
|
||||
|
||||
ThreadingHTTPServer((opt("--host"), int(opt("--port"))), Handler).serve_forever()
|
||||
23
scripts/ui-pruefung/fokus-aktualisierung-knopf.mjs
Normal file
23
scripts/ui-pruefung/fokus-aktualisierung-knopf.mjs
Normal file
@ -0,0 +1,23 @@
|
||||
import { start } from './lib.mjs';
|
||||
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112';
|
||||
const pw = process.argv[2];
|
||||
const b = await start();
|
||||
const aendern = a => `(async () => { const cs = document.body.getAttribute('data-csrf'); await fetch('/ui/modelle/${a}', {method:'POST', redirect:'manual', headers:{'content-type':'application/x-www-form-urlencoded'}, body:new URLSearchParams({csrf: cs, name: 'zweit'})}); return 1; })()`;
|
||||
const aktiv = `JSON.stringify({tag: document.activeElement.tagName, text: (document.activeElement.textContent || '').trim().slice(0, 14), titel: document.activeElement.title || '', zeile: (document.activeElement.closest('tr') || {textContent: ''}).textContent.trim().slice(0, 10), wert: document.activeElement.value || ''})`;
|
||||
try {
|
||||
await b.login(BASE, 'claude', pw);
|
||||
await b.viewport(1200, 800, { dsf: 1, mobile: false });
|
||||
await b.goto(BASE + '/ui/modelle');
|
||||
await b.eval(aendern('entladen')); await new Promise(r => setTimeout(r, 5000));
|
||||
await b.goto(BASE + '/ui/modelle');
|
||||
// Fall 1: Knopf „Bearbeiten“ der Zeile testmodell
|
||||
await b.eval(`(() => { const k = Array.from(document.querySelectorAll('button[data-dialog]')).find(x => x.closest('tr').textContent.includes('testmodell')); k.focus(); return 1; })()`);
|
||||
console.log('Knopf fokussiert:', await b.eval(aktiv));
|
||||
await b.eval(aendern('laden')); await new Promise(r => setTimeout(r, 9000));
|
||||
console.log('9 s später :', await b.eval(aktiv));
|
||||
// Fall 2: Auswahlfeld „Alle: Engine“
|
||||
await b.eval(`(() => { const s = document.querySelector('select'); s.focus(); return 1; })()`);
|
||||
console.log('Auswahl fokussiert:', await b.eval(aktiv));
|
||||
await b.eval(aendern('entladen')); await new Promise(r => setTimeout(r, 9000));
|
||||
console.log('9 s später :', await b.eval(aktiv));
|
||||
} finally { b.close(); }
|
||||
26
scripts/ui-pruefung/fokus-aktualisierung.mjs
Normal file
26
scripts/ui-pruefung/fokus-aktualisierung.mjs
Normal file
@ -0,0 +1,26 @@
|
||||
import { start } from './lib.mjs';
|
||||
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112';
|
||||
const pw = process.argv[2]; const tag = process.argv[3] || 'vorher';
|
||||
const b = await start();
|
||||
const lade = n => `(async () => { const cs = document.body.getAttribute('data-csrf'); const r = await fetch('/ui/modelle/${n}', {method:'POST', redirect:'manual', headers:{'content-type':'application/x-www-form-urlencoded'}, body:new URLSearchParams({csrf: cs, name: 'zweit'})}); return r.type; })()`;
|
||||
try {
|
||||
await b.login(BASE, 'claude', pw);
|
||||
await b.viewport(1200, 800, { dsf: 1, mobile: false });
|
||||
// Teil 1: offener Dialog mit ungesendetem Wert
|
||||
await b.goto(BASE + '/ui/modelle');
|
||||
await b.eval(`(() => { const k = Array.from(document.querySelectorAll('button[data-dialog]')).find(x => x.closest('tr') && x.closest('tr').textContent.includes('testmodell')); k.click(); const d = document.querySelector('dialog[open]'); const i = d.querySelector('input[name=vram_mb]'); i.focus(); i.value = '4321'; window.__dlg = d.id; return d.id; })()`);
|
||||
console.log('Dialog offen, Wert getippt:', await b.eval(`JSON.stringify({offen: !!document.querySelector('dialog[open]'), wert: document.querySelector('dialog[open] input[name=vram_mb]').value})`));
|
||||
await b.eval(lade('laden'));
|
||||
await new Promise(r => setTimeout(r, 9000));
|
||||
console.log('9 s nach Änderung einer anderen Zeile:', await b.eval(`JSON.stringify({offen: !!document.querySelector('dialog[open]'), wert: (document.getElementById(window.__dlg) && document.getElementById(window.__dlg).querySelector('input[name=vram_mb]').value), zeileZweit: (Array.from(document.querySelectorAll('tbody tr')).find(t => t.textContent.includes('zweit')) || {textContent: ''}).textContent.replace(/\\s+/g, ' ').slice(-70)})`));
|
||||
// Teil 2: Filter mit Cursor mitten im Text
|
||||
await b.eval(`(() => { const d = document.querySelector('dialog[open]'); if (d) d.close(); return 1; })()`);
|
||||
await b.eval(`(async () => { const cs = document.body.getAttribute('data-csrf'); await fetch('/ui/modelle/entladen', {method:'POST', redirect:'manual', headers:{'content-type':'application/x-www-form-urlencoded'}, body:new URLSearchParams({csrf: cs, name: 'zweit'})}); return 1; })()`);
|
||||
await new Promise(r => setTimeout(r, 5000));
|
||||
await b.goto(BASE + '/ui/modelle');
|
||||
await b.eval(`(() => { const f = document.querySelector('input[placeholder^="Name"]'); f.focus(); f.value = 'testmodel'; f.dispatchEvent(new Event('input', {bubbles: true})); f.setSelectionRange(4, 4); window.__f = 1; return 1; })()`);
|
||||
console.log('Filter fokussiert, Cursor an Position 4:', await b.eval(`JSON.stringify({aktiv: document.activeElement.tagName + '/' + (document.activeElement.type || ''), wert: document.activeElement.value, cursor: document.activeElement.selectionStart})`));
|
||||
await b.eval(lade('laden'));
|
||||
await new Promise(r => setTimeout(r, 9000));
|
||||
console.log('9 s nach Änderung einer anderen Zeile:', await b.eval(`JSON.stringify({aktiv: document.activeElement.tagName + '/' + (document.activeElement.type || ''), wert: document.activeElement.value, cursor: document.activeElement.selectionStart, filterWert: (document.querySelector('input[placeholder^="Name"]') || {}).value})`));
|
||||
} finally { b.close(); }
|
||||
18
scripts/ui-pruefung/fokusring.mjs
Normal file
18
scripts/ui-pruefung/fokusring.mjs
Normal file
@ -0,0 +1,18 @@
|
||||
import { start } from './lib.mjs';
|
||||
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112';
|
||||
const pw = process.argv[2]; const S = process.argv[3];
|
||||
const b = await start();
|
||||
try {
|
||||
await b.login(BASE, 'claude', pw);
|
||||
await b.viewport(1200, 800, { dsf: 2, mobile: false });
|
||||
for (const theme of ['light', 'dark']) {
|
||||
await b.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: theme }] });
|
||||
await b.goto(BASE + '/ui/chat');
|
||||
for (const [name, sel] of [['Knopf', '#chat button[type=submit]'], ['Link', 'header nav a'], ['Feld', '#chat textarea'], ['Auswahl', '#chat select']]) {
|
||||
await b.send('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Tab', code: 'Tab' }); await b.send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Tab', code: 'Tab' });
|
||||
const r = await b.eval(`(() => { const e = document.querySelector(${JSON.stringify(sel)}); e.focus(); const cs = getComputedStyle(e); return JSON.stringify({ trifft: e.matches(':focus-visible'), outline: cs.outlineStyle + ' ' + cs.outlineWidth + ' ' + cs.outlineColor, boxShadow: cs.boxShadow.slice(0, 40) }); })()`);
|
||||
console.log(theme, name.padEnd(8), r);
|
||||
}
|
||||
await b.shot(`${S}/cdp/fokus-${theme}.png`);
|
||||
}
|
||||
} finally { b.close(); }
|
||||
64
scripts/ui-pruefung/kontrast.mjs
Normal file
64
scripts/ui-pruefung/kontrast.mjs
Normal file
@ -0,0 +1,64 @@
|
||||
import { start } from './lib.mjs';
|
||||
const BASE = process.env.NEXUS_BASE || 'http://127.0.0.1:18112';
|
||||
const pw = process.argv[2]; const tag = process.argv[3] || 'vorher';
|
||||
const b = await start();
|
||||
const mess = `(() => {
|
||||
const parse = c => { const m = c.match(/rgba?\\(([^)]+)\\)/); if (!m) return null; const p = m[1].split(/[ ,\\/]+/).filter(Boolean).map(Number); return { r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1 }; };
|
||||
const lin = v => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); };
|
||||
const lum = c => 0.2126 * lin(c.r) + 0.7152 * lin(c.g) + 0.0722 * lin(c.b);
|
||||
const mix = (top, bot) => ({ r: top.r * top.a + bot.r * (1 - top.a), g: top.g * top.a + bot.g * (1 - top.a), b: top.b * top.a + bot.b * (1 - top.a), a: 1 });
|
||||
const ratio = (f, bg) => { const F = mix(f, bg); const l1 = lum(F), l2 = lum(bg); return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05); };
|
||||
const seiten = getComputedStyle(document.body).backgroundColor;
|
||||
function hintergruende(e) { // Liste möglicher Hintergrundfarben (Verlaufsstopps zählen einzeln)
|
||||
let ketten = [{ r: 246, g: 243, b: 239, a: 1 }];
|
||||
const alle = []; for (let x = e; x; x = x.parentElement) alle.push(x);
|
||||
let basis = parse(getComputedStyle(document.documentElement).backgroundColor); if (!basis || basis.a === 0) basis = null;
|
||||
const bodyBg = parse(getComputedStyle(document.body).backgroundColor); if (bodyBg && bodyBg.a > 0) basis = bodyBg;
|
||||
let stack = [basis || { r: 255, g: 255, b: 255, a: 1 }];
|
||||
for (const x of alle.reverse()) {
|
||||
const cs = getComputedStyle(x); const bc = parse(cs.backgroundColor); const bi = cs.backgroundImage;
|
||||
const neu = [];
|
||||
const stops = bi && bi !== 'none' ? (bi.match(/rgba?\\([^)]*\\)/g) || []).map(parse).filter(Boolean) : [];
|
||||
for (const s of stack) {
|
||||
let g = s; if (bc && bc.a > 0) g = mix(bc, s);
|
||||
if (stops.length) { for (const st of stops) neu.push(mix(st, g)); } else { neu.push(g); }
|
||||
}
|
||||
stack = neu.length > 8 ? neu.slice(0, 8) : neu;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
const sicht = e => { const r = e.getBoundingClientRect(); const s = getComputedStyle(e); return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none' && parseFloat(s.opacity) > 0.05; };
|
||||
const treffer = {}; const gesamt = {};
|
||||
document.querySelectorAll('body *').forEach(e => {
|
||||
if (!sicht(e)) return;
|
||||
const direkt = Array.from(e.childNodes).filter(n => n.nodeType === 3 && n.textContent.trim().length > 1).map(n => n.textContent.trim()).join(' ');
|
||||
if (!direkt) return;
|
||||
if (e.closest('svg,script,style')) return;
|
||||
const cs = getComputedStyle(e); const f = parse(cs.color); if (!f) return;
|
||||
const gross = parseFloat(cs.fontSize) >= 24 || (parseFloat(cs.fontSize) >= 18.66 && parseInt(cs.fontWeight, 10) >= 700);
|
||||
const grenze = gross ? 3 : 4.5;
|
||||
let min = 99; let bgMin = null;
|
||||
for (const bg of hintergruende(e)) { const q = ratio(f, bg); if (q < min) { min = q; bgMin = bg; } }
|
||||
const schl = e.tagName.toLowerCase() + (e.className && typeof e.className === 'string' ? '.' + e.className.trim().split(/\\s+/).slice(0, 2).join('.') : '') + (e.closest('a') && e.tagName !== 'A' ? '(in a)' : '') ;
|
||||
gesamt[schl] = (gesamt[schl] || 0) + 1;
|
||||
if (min < grenze) { const k = schl; if (!treffer[k] || treffer[k].q > min) treffer[k] = { q: Math.round(min * 100) / 100, grenze, text: direkt.slice(0, 22), fg: cs.color, bg: 'rgb(' + Math.round(bgMin.r) + ',' + Math.round(bgMin.g) + ',' + Math.round(bgMin.b) + ')', n: 0 }; treffer[k].n = (treffer[k].n || 0) + 1; }
|
||||
});
|
||||
return JSON.stringify({ elemente: Object.values(gesamt).reduce((a, c) => a + c, 0), unter: Object.entries(treffer).sort((a, c) => a[1].q - c[1].q).map(([k, v]) => k + ' ' + v.q + ' (min ' + v.grenze + ') "' + v.text + '" ' + v.fg + ' auf ' + v.bg + ' x' + v.n) });
|
||||
})()`;
|
||||
const seiten = ['/ui', '/ui/modelle', '/ui/modelle?art=sprache', '/ui/engines', '/ui/chat', '/ui/personas', '/ui/keys', '/ui/warteschlange', '/ui/anfragen', '/ui/audit', '/ui/benutzer', '/ui/konto'];
|
||||
try {
|
||||
await b.login(BASE, 'claude', pw);
|
||||
await b.viewport(1200, 900, { dsf: 1, mobile: false });
|
||||
for (const theme of ['light', 'dark']) {
|
||||
await b.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: theme }] });
|
||||
const alle = {};
|
||||
for (const p of seiten) {
|
||||
await b.goto(BASE + p);
|
||||
const r = JSON.parse(await b.eval(mess));
|
||||
r.unter.forEach(u => { const k = u.replace(/ x\d+$/, ''); alle[k] = (alle[k] || []).concat(p); });
|
||||
if (p === '/ui/modelle') await b.shot(`${process.argv[4] || '/tmp'}/kontrast-${tag}-${theme}.png`);
|
||||
}
|
||||
console.log('=== ' + theme + ' (' + Object.keys(alle).length + ' Befunde)');
|
||||
Object.entries(alle).slice(0, 40).forEach(([k, v]) => console.log(k, ' ← ' + [...new Set(v)].join(', ')));
|
||||
}
|
||||
} finally { b.close(); }
|
||||
29
scripts/ui-pruefung/lib.mjs
Normal file
29
scripts/ui-pruefung/lib.mjs
Normal file
@ -0,0 +1,29 @@
|
||||
// Kleiner Treiber für Chromium über das DevTools-Protokoll (nur lokal, für UI-Tests).
|
||||
import { spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
export async function start({ port = 9333 } = {}) {
|
||||
const dir = fs.mkdtempSync('/tmp/cdp-prof-');
|
||||
const proc = spawn('/usr/bin/chromium', ['--headless=new', '--no-sandbox', '--disable-gpu', `--remote-debugging-port=${port}`, `--user-data-dir=${dir}`, 'about:blank'], { stdio: 'ignore' });
|
||||
let info;
|
||||
for (let i = 0; i < 50; i++) {
|
||||
try { info = await (await fetch(`http://127.0.0.1:${port}/json`)).json(); if (info.length) break; } catch { /* warten */ }
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
}
|
||||
const page = info.find(t => t.type === 'page');
|
||||
const ws = new WebSocket(page.webSocketDebuggerUrl);
|
||||
await new Promise(r => ws.addEventListener('open', r));
|
||||
let id = 0; const wait = new Map(); const events = [];
|
||||
ws.addEventListener('message', m => { const d = JSON.parse(m.data); if (d.id && wait.has(d.id)) { wait.get(d.id)(d); wait.delete(d.id); } else if (d.method) events.push(d); });
|
||||
const send = (method, params = {}) => new Promise((res, rej) => { const i = ++id; wait.set(i, d => d.error ? rej(new Error(JSON.stringify(d.error))) : res(d.result)); ws.send(JSON.stringify({ id: i, method, params })); });
|
||||
await send('Page.enable'); await send('Runtime.enable');
|
||||
const api = {
|
||||
send, events,
|
||||
async viewport(width, height, { dsf = 1, mobile = true } = {}) { await send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: dsf, mobile }); },
|
||||
async goto(url) { await send('Page.navigate', { url }); await new Promise(r => setTimeout(r, 1500)); },
|
||||
async eval(expr) { const r = await send('Runtime.evaluate', { expression: expr, awaitPromise: true, returnByValue: true }); if (r.exceptionDetails) throw new Error(JSON.stringify(r.exceptionDetails.exception?.description || r.exceptionDetails)); return r.result.value; },
|
||||
async shot(file, { full = false } = {}) { const r = await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: full }); fs.writeFileSync(file, Buffer.from(r.data, 'base64')); },
|
||||
async login(base, name, pw) { await api.goto(base + '/ui/login'); await api.eval(`fetch('/ui/login',{method:'POST',headers:{'content-type':'application/x-www-form-urlencoded'},body:new URLSearchParams({name:${JSON.stringify(name)},passwort:${JSON.stringify(pw)}}),redirect:'manual'}).then(r=>r.type)`); },
|
||||
close() { try { ws.close(); } catch {} proc.kill('SIGKILL'); fs.rmSync(dir, { recursive: true, force: true }); },
|
||||
};
|
||||
return api;
|
||||
}
|
||||
29
scripts/ui-pruefung/streaming-scroll.mjs
Normal file
29
scripts/ui-pruefung/streaming-scroll.mjs
Normal file
@ -0,0 +1,29 @@
|
||||
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(); }
|
||||
34
scripts/ui-pruefung/ueberlagerung.mjs
Normal file
34
scripts/ui-pruefung/ueberlagerung.mjs
Normal file
@ -0,0 +1,34 @@
|
||||
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];
|
||||
const b = await start();
|
||||
const pruefen = `(async () => {
|
||||
const sicht = e => { const s = getComputedStyle(e); const r = e.getBoundingClientRect(); return s.visibility !== 'hidden' && s.display !== 'none' && r.width > 0 && r.height > 0; };
|
||||
const ziele = Array.from(document.querySelectorAll('#chat button, #chat select, #chat textarea, #chat input, .chat-seite button, .chat-seite input, header a, header button')).filter(sicht);
|
||||
const probleme = []; let n = 0;
|
||||
for (const e of ziele) {
|
||||
e.scrollIntoView({ block: 'center', inline: 'nearest' });
|
||||
await new Promise(r => setTimeout(r, 15));
|
||||
const r = e.getBoundingClientRect(); const cx = Math.min(Math.max(r.left + r.width / 2, 1), innerWidth - 1), cy = Math.min(Math.max(r.top + r.height / 2, 1), innerHeight - 1);
|
||||
const top = document.elementFromPoint(cx, cy); n++;
|
||||
if (!(top === e || e.contains(top) || (top && top.closest('label') && top.closest('label').contains(e)))) probleme.push((e.id || e.tagName) + ':' + (e.textContent || e.name || '').trim().slice(0, 14) + ' verdeckt von ' + (top ? top.tagName + (top.id ? '#' + top.id : '') + '.' + String(top.className).slice(0, 20) : 'nichts'));
|
||||
}
|
||||
const hint = Array.from(document.querySelectorAll('main p')).find(e => e.textContent.trim().startsWith('Der Chat läuft mit den Rechten'));
|
||||
const karte = document.getElementById('chat');
|
||||
const hr = hint.getBoundingClientRect(), kr = karte.getBoundingClientRect();
|
||||
const hinweisUeberKarte = hr.top + scrollY < kr.bottom + scrollY - 1;
|
||||
const querScroll = document.documentElement.scrollWidth > innerWidth + 1;
|
||||
return JSON.stringify({vp: [innerWidth, innerHeight], elemente: n, verdeckt: probleme, hinweisUeberKarte, querScroll});
|
||||
})()`;
|
||||
const fall = [[390,844,false,'390x844'],[390,844,true,'390x844 + Verlauf an'],[320,568,false,'320x568'],[320,568,true,'320x568 + Verlauf an'],[844,390,false,'Querformat 844x390'],[844,390,true,'Querformat + Verlauf an'],[390,380,false,'Tastatur 390x380'],[320,320,false,'Tastatur 320x320'],[195,422,false,'200% Zoom von 390x844'],[160,284,false,'200% Zoom von 320x568'],[1290,952,false,'Desktop 1290x952'],[1290,952,true,'Desktop, Verlauf aus']];
|
||||
try {
|
||||
await b.login(BASE, 'claude', pw);
|
||||
for (const [w, h, sidebar, name] of fall) {
|
||||
await b.viewport(w, h, { dsf: 1, mobile: w < 700 });
|
||||
await b.goto(BASE + '/ui/chat');
|
||||
// Seitenleiste: mobil ist sie standardmäßig zu (display:none ohne Klasse), „Verlauf ein/aus“ schaltet; Desktop: offen, true = zuklappen
|
||||
if (sidebar) await b.eval(`document.getElementById('chat-seite-knopf').click(); 1`);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
console.log(name.padEnd(28), await b.eval(pruefen));
|
||||
}
|
||||
} finally { b.close(); }
|
||||
Reference in New Issue
Block a user