Der Backstage-Zwischenraum (b44ae093) nutzte die Vorsilbe zr- – dieselbe
wie das Ziele-Formular der Regie (#zr-vorschau, zr-titel). Seine Regeln
(u. a. .zr-vorschau mit Spiegelung) verschoben die Ziele-Vorschau um 15 px;
gefunden von mess-serverziele, am Stand vor meinen Runden gegengemessen.
- 256 Stellen in zwischenraum.js/.css und ihren Prüfungen auf bz- umbenannt;
das Ziele-Formular selbst unverändert.
- Neue Wache in pruef-reaktion (Abschnitt 35): keine Element-Kennung darf
aus zwei Dateien der Saal-Seite kommen – abgeleitet aus reaktion.html und
seinen 46 Skripten; die echte Kollision von heute wird erkannt.
- pruef-reaktion 1104/0, mess-serverziele, zwischenraum-blick, mess-reaktion grün.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
500 lines
32 KiB
JavaScript
500 lines
32 KiB
JavaScript
/* =====================================================================
|
||
WIE DER GEPRÜFTE ZWISCHENRAUM AUSSIEHT UND WIRKT (04.11.2026, Neuplan C5)
|
||
|
||
`pruef-reaktion` (Abschnitt 31) prüft die Schnittstelle. Hier wird im
|
||
echten Browser mit Ersatzkamera und Ersatzmikro gemessen, was nur dort
|
||
zu sehen ist:
|
||
* Nach „Dabei sein“ steht der Backstage in der Chatspalte, nie über
|
||
dem Video, und alle fünf Schritte sagen etwas GEMESSENES.
|
||
* Die Vorschau zeigt DIESELBE Kamera, die später hinausgeht.
|
||
* Die Regie sieht dieselben Stufen wie der Gast (gefunden: bis zu 8 s
|
||
„zu dunkel“ vom Kamerastart), den Zuruf, „bereit ✓“ – und die
|
||
Karte sprengt das seitliche Pult nicht (gefunden: 309 px Zeile,
|
||
0 px Regie-Inhalt, 47 px über der Videoleiste).
|
||
* „Auf die Bühne“ bringt ihn hinauf, die Kamera läuft weiter.
|
||
* Am Handy: höchstens 62 % Höhe, „Ich bin bereit“ ohne Rollen, Chat
|
||
mindestens 100 px (gefunden: 16 px), Tippziele 44 px.
|
||
* Aus dem Backstage genommen: Feld zu UND Kamera aus (gefunden: das
|
||
Lämpchen blieb an).
|
||
Gegenproben sind am 04.11.2026 von Hand gelaufen (Pult-Regel entfernt
|
||
→ zwei Zeilen rot); die Zusicherungen messen gerenderte Größen, nicht
|
||
Klassen.
|
||
|
||
DREI AUSGÄNGE: 0 in Ordnung · 1 Befund · 3 konnte nicht nachsehen.
|
||
Bilder: ZR_BILDER=<ordner> node server/pruef-zwischenraum-blick.mjs
|
||
NIE DIE ECHTE DATENBANK – eigener Ordner, eigener Port.
|
||
===================================================================== */
|
||
import { mkdtempSync, rmSync, readFileSync } from "node:fs";
|
||
import { tmpdir } from "node:os";
|
||
import { join, dirname } from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
import { request } from "node:http";
|
||
import { createServer as httpsServer } from "node:https";
|
||
import { zertifikatBauen } from "./helfer-openssl.mjs";
|
||
import { notbremse } from "./helfer-notbremse.mjs";
|
||
import { eigenerPort } from "./helfer-port.mjs";
|
||
|
||
const HIER = dirname(fileURLToPath(import.meta.url));
|
||
const ordner = mkdtempSync(join(tmpdir(), "pruef-zwischenraum-"));
|
||
process.env.WORKSPACE_DB = join(ordner, "workspace.db");
|
||
|
||
const PORT = await eigenerPort(import.meta);
|
||
const HTTPS_PORT = await eigenerPort(import.meta, "pruef-zwischenraum-blick (HTTPS)", 1);
|
||
process.env.PORT = `${PORT}`;
|
||
process.env.SITE_ACCESS_SECRET = "lokaler-test";
|
||
process.env.SITE_PUBLIC_LAUNCH_AT = "2020-01-01T00:00:00+01:00";
|
||
|
||
const express = (await import("express")).default;
|
||
/* Der Sitzungskeks ist `secure`. Der Vorbau unten spricht https, der
|
||
Server dahinter nicht -- ohne diesen Griff setzt er den Keks und
|
||
der Browser verwirft ihn. */
|
||
const ec = express.response.cookie;
|
||
express.response.cookie = function (n, w, o) { return ec.call(this, n, w, { ...(o || {}), secure: false }); };
|
||
await import("./index.js");
|
||
notbremse(300_000, "pruef-zwischenraum-blick");
|
||
await new Promise((r) => setTimeout(r, 1000));
|
||
|
||
const CREW = "crew.dogfather-universe.com";
|
||
|
||
/* ---------- Leute ------------------------------------------------------- */
|
||
const { DatabaseSync } = await import("node:sqlite");
|
||
const { scryptSync, randomBytes, createHmac } = await import("node:crypto");
|
||
const d = new DatabaseSync(process.env.WORKSPACE_DB);
|
||
const kenn = randomBytes(32).toString("hex");
|
||
d.prepare("INSERT INTO einstellungen (schluessel, wert, geaendert, von)"
|
||
+ " VALUES (?,?,?,NULL) ON CONFLICT(schluessel) DO NOTHING")
|
||
.run("code_kennung_schluessel", kenn, new Date().toISOString());
|
||
const ALT = new Date(Date.now() - 200 * 86400000).toISOString();
|
||
function anlegen(name, rolle, code) {
|
||
const salt = randomBytes(16).toString("hex");
|
||
const hash = scryptSync(code, salt, 64,
|
||
{ N: 32768, r: 8, p: 1, maxmem: 96 * 1024 * 1024 }).toString("hex");
|
||
d.prepare("INSERT INTO personen (name, rolle, code_hash, code_salt, code_n,"
|
||
+ " code_kennung, aktiv, erstellt) VALUES (?,?,?,?,?,?,1,?)")
|
||
.run(name, rolle, hash, salt, 32768,
|
||
createHmac("sha256", kenn).update(code).digest("hex"), ALT);
|
||
}
|
||
const CODES = {
|
||
admin: "CODE-M00-000001", hand: "CODE-M01-000001",
|
||
gast: "CODE-M02-000001", gast2: "CODE-M03-000001",
|
||
};
|
||
/* VANVAN IST DIE RECHTE HAND und wird mitgemessen, nicht nur
|
||
DogFather: Filipe hat "nur ich und vanvan" gesagt, und ob die
|
||
zweite Haelfte davon stimmt, sieht man nur, wenn sie dabei ist. */
|
||
anlegen("DogFather", "admin", CODES.admin);
|
||
anlegen("VanVan", "hand", CODES.hand);
|
||
anlegen("Nachtfalter", "gast", CODES.gast);
|
||
anlegen("Lenny", "gast", CODES.gast2);
|
||
d.close();
|
||
|
||
function roh(pfad, { method = "GET", keks = "", rumpf = null } = {}) {
|
||
return new Promise((fertig, schief) => {
|
||
const daten = rumpf === null ? null : Buffer.from(JSON.stringify(rumpf));
|
||
const a = request({
|
||
host: "127.0.0.1", port: PORT, path: pfad, method,
|
||
headers: {
|
||
Host: CREW, Origin: `https://${CREW}`,
|
||
...(keks ? { Cookie: keks } : {}),
|
||
...(daten ? { "Content-Type": "application/json", "Content-Length": daten.length } : {}),
|
||
},
|
||
}, (antwort) => {
|
||
const teile = [];
|
||
antwort.on("data", (s) => teile.push(s));
|
||
antwort.on("end", () => {
|
||
const text = Buffer.concat(teile).toString("utf8");
|
||
let j = null; try { j = JSON.parse(text); } catch { /* kein JSON */ }
|
||
fertig({ code: antwort.statusCode, text, j, kopf: antwort.headers });
|
||
});
|
||
});
|
||
a.on("error", schief);
|
||
if (daten) a.write(daten);
|
||
a.end();
|
||
});
|
||
}
|
||
async function anmelden(wer) {
|
||
const a = await roh("/workspace/api/anmelden", {
|
||
method: "POST",
|
||
rumpf: { rolle: wer === "gast2" ? "gast" : wer, code: CODES[wer], alter_ok: true },
|
||
});
|
||
return [].concat(a.kopf["set-cookie"] || []).map((z) => z.split(";")[0]).join("; ");
|
||
}
|
||
const k = {
|
||
admin: await anmelden("admin"),
|
||
hand: await anmelden("hand"),
|
||
gast: await anmelden("gast"),
|
||
gast2: await anmelden("gast2"),
|
||
};
|
||
|
||
/* ---------- Zaehlwerk --------------------------------------------------- */
|
||
let fehler = 0;
|
||
let geprueft = 0;
|
||
const ok = (b, t) => {
|
||
geprueft++;
|
||
console.log((b ? " ok " : " FEHL ") + t);
|
||
if (!b) fehler++;
|
||
};
|
||
function nichtNachsehbar(grund) {
|
||
console.log("\n -- NICHT NACHSEHBAR");
|
||
console.log(` ${grund}`);
|
||
console.log(" Das ist KEIN Befund am Code -- es heisst nur, dass");
|
||
console.log(" gerade niemand nachsehen konnte.\n");
|
||
try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ }
|
||
process.exit(3);
|
||
}
|
||
|
||
/* ---------- Die Buehne fuellen ------------------------------------------ */
|
||
/* ZWEI STUECKE IN DER WARTESCHLANGE, EINES MIT TERMIN UND EINES OHNE.
|
||
Genau das ist die Aussage der linken Reihe ("was keinen hat, steht
|
||
unten"), und mit nur einem Eintrag liesse sie sich nicht messen. */
|
||
for (const adresse of ["https://youtu.be/9bZkp7q19f0",
|
||
"https://www.youtube.com/watch?v=kJQP7kiw5Fk"]) {
|
||
const a = await roh("/workspace/api/reaktion/liste", {
|
||
method: "POST", keks: k.admin, rumpf: { video: adresse },
|
||
});
|
||
if (a.code >= 400) nichtNachsehbar(`Die Warteschlange nimmt nichts an (HTTP ${a.code}).`);
|
||
}
|
||
const liste0 = (await roh("/workspace/api/reaktion", { keks: k.admin })).j?.liste || [];
|
||
if (liste0.length !== 2) {
|
||
nichtNachsehbar(`In der Warteschlange stehen ${liste0.length} Stuecke statt 2.`);
|
||
}
|
||
|
||
/* Der Termin liegt in der ZUKUNFT und wird relativ gerechnet. Ein
|
||
festes Datum waere eine Zeitbombe: Es ist richtig, bis der Kalender
|
||
es einholt -- und dann schlaegt "ueberfaellig" an, ohne dass etwas
|
||
kaputt ist. */
|
||
{
|
||
const a = await roh(`/workspace/api/reaktion/liste/${liste0[0].id}/wann`, {
|
||
method: "PUT", keks: k.admin,
|
||
rumpf: { wann: new Date(Date.now() + 3 * 86400000).toISOString() },
|
||
});
|
||
if (a.code >= 400) nichtNachsehbar(`Der Termin laesst sich nicht setzen (HTTP ${a.code}).`);
|
||
}
|
||
await roh("/workspace/api/reaktion", {
|
||
method: "PUT", keks: k.admin,
|
||
rumpf: {
|
||
titel: "Wir schauen den neuen Trailer",
|
||
video: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
||
beginnt_am: new Date(Date.now() + 7 * 60_000).toISOString(),
|
||
},
|
||
});
|
||
|
||
/* ---------- Der Vorbau -------------------------------------------------- */
|
||
const schluesselDatei = join(ordner, "p.key");
|
||
const zertDatei = join(ordner, "p.crt");
|
||
try {
|
||
zertifikatBauen(schluesselDatei, zertDatei, CREW);
|
||
} catch (f) {
|
||
nichtNachsehbar(`Kein Zertifikat zu bauen: ${f?.message}\n`
|
||
+ " openssl liegt bei Git in mingw64/bin -- im System-PATH\n"
|
||
+ " steht oft nur Git/cmd.");
|
||
}
|
||
const vorbau = httpsServer({
|
||
key: readFileSync(schluesselDatei), cert: readFileSync(zertDatei),
|
||
}, (von, nach) => {
|
||
const weiter = request({
|
||
host: "127.0.0.1", port: PORT, path: von.url, method: von.method,
|
||
headers: { ...von.headers, host: `${CREW}:${HTTPS_PORT}` },
|
||
}, (antwort) => {
|
||
nach.writeHead(antwort.statusCode || 502, antwort.headers);
|
||
antwort.pipe(nach);
|
||
});
|
||
weiter.on("error", () => { try { nach.writeHead(502); nach.end(); } catch { /* egal */ } });
|
||
von.pipe(weiter);
|
||
});
|
||
await new Promise((r) => vorbau.listen(HTTPS_PORT, "127.0.0.1", r));
|
||
const BASIS = `https://${CREW}:${HTTPS_PORT}`;
|
||
const IDS = {};
|
||
{
|
||
const dd = new DatabaseSync(process.env.WORKSPACE_DB);
|
||
for (const [w, n] of [["admin", "DogFather"], ["hand", "VanVan"], ["gast", "Nachtfalter"], ["gast2", "Lenny"]]) IDS[w] = dd.prepare("SELECT id FROM personen WHERE name = ?").get(n).id;
|
||
dd.close();
|
||
}
|
||
for (const st of ["vorbereitung", "live"]) await roh("/workspace/api/reaktion/stand", { method: "POST", keks: k.admin, rumpf: { stand: st } });
|
||
const standNun = (await roh("/workspace/api/reaktion", { keks: k.admin })).j?.stand;
|
||
if (standNun !== "live") nichtNachsehbar(`Die Sendung geht nicht live (${standNun}).`);
|
||
|
||
const pw = await import("file:///C:/Users/qciga/Documents/Obelix/Analyse/node_modules/playwright/index.mjs");
|
||
const browser = await pw.chromium.launch({
|
||
args: [`--host-resolver-rules=MAP ${CREW} 127.0.0.1`, "--ignore-certificate-errors",
|
||
"--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--autoplay-policy=no-user-gesture-required"],
|
||
});
|
||
/* Bilder nur auf Wunsch: ZR_BILDER=<ordner> node server/pruef-zwischenraum-blick.mjs */
|
||
const BILDER = process.env.ZR_BILDER || "";
|
||
async function als(wer, breite, hoehe) {
|
||
const kontext = await browser.newContext({ viewport: { width: breite, height: hoehe }, hasTouch: breite <= 860, ignoreHTTPSErrors: true });
|
||
await kontext.grantPermissions(["camera", "microphone"], { origin: BASIS });
|
||
await kontext.addCookies((k[wer] || "").split("; ").filter(Boolean).map((z) => {
|
||
const [n, ...r] = z.split("=");
|
||
return { name: n, value: r.join("="), domain: CREW, path: "/" };
|
||
}));
|
||
const seite = await kontext.newPage();
|
||
const konsole = [];
|
||
seite.on("pageerror", (f) => konsole.push(String(f?.message || f)));
|
||
seite.on("console", (m) => { if (m.type() === "error" && !/compute-pressure|youtube|ytimg|googlevideo|livekit|ERR_|net::/i.test(m.text())) konsole.push(m.text()); });
|
||
await seite.goto(`${BASIS}/workspace/reaktion.html`, { waitUntil: "domcontentloaded" });
|
||
await seite.waitForSelector("body[data-stand]", { timeout: 20000 });
|
||
await seite.waitForTimeout(1200);
|
||
return { kontext, seite, konsole };
|
||
}
|
||
const sichtbar = (seite, sel) => seite.evaluate((s) => { const e = document.querySelector(s); if (!e) return false; const r = e.getBoundingClientRect(); const st = getComputedStyle(e); return !e.hidden && st.display !== "none" && r.width > 0 && r.height > 0; }, sel);
|
||
|
||
const regie = await als("admin", 1440, 900);
|
||
const gast = await als("gast", 1280, 800);
|
||
|
||
/* ---- Einladen, zusagen ---- */
|
||
await roh("/workspace/api/reaktion/gast", { method: "POST", keks: k.admin, rumpf: { person_id: IDS.gast } });
|
||
await gast.seite.waitForSelector("#vorraum:not([hidden])", { timeout: 15000 });
|
||
await gast.seite.waitForTimeout(1200);
|
||
await gast.seite.click("#vorraum-ja");
|
||
await gast.seite.waitForSelector("#bz-gast:not([hidden])", { timeout: 15000 }).catch(() => {});
|
||
ok(await sichtbar(gast.seite, "#bz-gast"), "nach „Dabei sein“ steht der Backstage in der Chatspalte");
|
||
ok(!(await sichtbar(gast.seite, "#vorraum")), "der Einladungsdialog ist zu");
|
||
/* Warten, bis alle Messungen etwas sagen – höchstens 12 s. */
|
||
await gast.seite.waitForFunction(() => [...document.querySelectorAll("#bz-gast .bz-schritt")].every((li) => li.dataset.stufe !== "offen"), null, { timeout: 12000 }).catch(() => {});
|
||
const stufen = await gast.seite.evaluate(() => Object.fromEntries([...document.querySelectorAll("#bz-gast .bz-schritt")].map((li) => [li.dataset.schritt, `${li.dataset.stufe}: ${li.textContent.trim()}`])));
|
||
console.log(" Schritte:", JSON.stringify(stufen, null, 1));
|
||
ok(Object.keys(stufen).length === 5 && Object.values(stufen).every((s) => !s.startsWith("offen")), "alle fünf Schritte haben eine gemessene Stufe");
|
||
ok(/^gut/.test(stufen.kamera) && /^(gut|knapp|schwach)/.test(stufen.licht) && /^(gut|knapp|schwach)/.test(stufen.ton) && /Mbit\/s/.test(stufen.leitung),
|
||
"Kamera an, Licht, Ton und Leitung sind GEMESSEN (mit Zahl), nicht vermutet");
|
||
const kamera = await gast.seite.evaluate(() => { const v = document.getElementById("bz-vorschau"); return { breite: v?.videoWidth || 0, gleich: v?.srcObject === window.SaalKamera?.strom?.(), live: (v?.srcObject?.getTracks?.() || []).every((t) => t.readyState === "live") }; });
|
||
ok(kamera.breite > 0 && kamera.gleich && kamera.live, `die Vorschau zeigt DIESELBE Kamera, die später hinausgeht (${kamera.breite} px breit, gleich=${kamera.gleich})`);
|
||
const lage1 = (await roh("/workspace/api/reaktion", { keks: k.admin })).j;
|
||
ok(!(lage1?.gaeste || []).some((g) => g.id === IDS.gast), "er steht noch NICHT auf der Bühne");
|
||
const geometrie = await gast.seite.evaluate(() => {
|
||
const r = (s) => document.querySelector(s)?.getBoundingClientRect();
|
||
const zr = r("#bz-gast"), lw = r("#leinwand"), sch = r("#schiene"), liste = r("#chat-liste");
|
||
const schnitt = (a, b) => a && b && a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
||
const klein = [...document.querySelectorAll("#bz-gast *")].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim()) && parseFloat(getComputedStyle(e).fontSize) < 11.5).map((e) => e.className);
|
||
return { ueberVideo: !!schnitt(zr, lw), inSchiene: !!(zr && sch && zr.left >= sch.left - 1 && zr.right <= sch.right + 1), chatHoehe: liste?.height || 0, klein };
|
||
});
|
||
ok(!geometrie.ueberVideo && geometrie.inSchiene, "der Backstage liegt in der Chatspalte, nie über dem Video");
|
||
ok(geometrie.chatHoehe > 60, `der Chat darunter bleibt sichtbar (${Math.round(geometrie.chatHoehe)} px)`);
|
||
|
||
/* ---- Licht in Mitte und Rand, Gegenlicht, Gesicht, Hinweis im Bild ----
|
||
Gemessen an KÜNSTLICHEN Bildern mit bekannter Antwort – so ist jede
|
||
Zusicherung zugleich ihre Gegenprobe (Gegenlicht MUSS erkannt werden,
|
||
gleichmäßiges Licht DARF es nicht). */
|
||
const bild = await gast.seite.evaluate(async () => {
|
||
const Z = window.Zwischenraum;
|
||
const malen = (rand, mitte) => { const c = document.createElement("canvas"); c.width = 320; c.height = 180;
|
||
const g = c.getContext("2d"); g.fillStyle = `rgb(${rand},${rand},${rand})`; g.fillRect(0, 0, 320, 180);
|
||
g.fillStyle = `rgb(${mitte},${mitte},${mitte})`; g.fillRect(110, 35, 100, 110); return c; };
|
||
const gegen = Z.lichtAusBild(malen(220, 60));
|
||
const gleich = Z.lichtAusBild(malen(150, 150));
|
||
const basis = { kamera: true, mikro: true, licht: 150, pegel_db: -20, echo: true, leitung_kbit: 3000 };
|
||
const b = (x) => Z.bewerten({ ...basis, ...x });
|
||
return {
|
||
gegen, gleich,
|
||
gegenWort: b({ licht: gegen.licht, licht_mitte: gegen.mitte, licht_rand: gegen.rand }).licht,
|
||
gleichWort: b({ licht: gleich.licht, licht_mitte: gleich.mitte, licht_rand: gleich.rand }).licht,
|
||
gegenHinweis: Z.bildHinweis({ ...basis, licht: gegen.licht, licht_mitte: gegen.mitte, licht_rand: gegen.rand }),
|
||
gutHinweis: Z.bildHinweis({ ...basis, licht_mitte: 150, licht_rand: 150 }),
|
||
gesichtNein: b({ gesicht: false }).kamera, gesichtJa: b({ gesicht: true }).kamera, gesichtUnbekannt: b({ gesicht: null }).kamera,
|
||
gesichtNeinHinweis: Z.bildHinweis({ ...basis, gesicht: false }),
|
||
leitungGut: b({ leitung_kbit: 1600 }).leitung, leitungKnapp: b({ leitung_kbit: 1000 }).leitung, leitungSchwach: b({ leitung_kbit: 400 }).leitung,
|
||
kann: await Z.gesichtPruefen(),
|
||
jetzt: document.querySelector('#bz-gast .bz-schritt[data-schritt="kamera"]')?.textContent.trim(),
|
||
hinweisDa: !document.getElementById("bz-bildhinweis")?.hidden,
|
||
oval: (() => { const o = document.querySelector("#bz-gast .bz-oval")?.getBoundingClientRect(); const r = document.querySelector("#bz-gast .bz-rahmen")?.getBoundingClientRect();
|
||
return !!(o && r && o.width > 10 && o.left >= r.left && o.right <= r.right && o.top >= r.top - 1 && o.bottom <= r.bottom + 1); })(),
|
||
};
|
||
});
|
||
console.log(" Bild:", JSON.stringify(bild));
|
||
ok(bild.gegen.rand - bild.gegen.mitte > 100 && Math.abs(bild.gleich.rand - bild.gleich.mitte) <= 2,
|
||
`Mitte und Rand werden getrennt gemessen (Gegenlicht ${bild.gegen.rand}/${bild.gegen.mitte}, gleichmäßig ${bild.gleich.rand}/${bild.gleich.mitte})`);
|
||
ok(bild.gegenWort[0] === "knapp" && /^Gegenlicht/.test(bild.gegenWort[1]) && bild.gegenHinweis === "Gegenlicht",
|
||
`Gegenlicht wird erkannt und steht im Bild („${bild.gegenWort[1]}“)`);
|
||
ok(bild.gleichWort[0] === "gut" && bild.gutHinweis === null, "Gegenprobe: gleichmäßiges Licht ist kein Gegenlicht, und im Bild steht dann nichts");
|
||
ok(bild.gesichtNein[0] === "knapp" && bild.gesichtNeinHinweis === "Gesicht nicht im Rahmen" && bild.gesichtJa[0] === "gut" && /Gesicht im Rahmen/.test(bild.gesichtJa[1]),
|
||
"Gesicht im Rahmen / nicht im Rahmen hat seine eigenen Sätze");
|
||
ok(bild.gesichtUnbekannt[1] === "Kamera an", "kann der Browser kein Gesicht erkennen, behauptet die Seite nichts darüber");
|
||
const rahmenFaelle = await gast.seite.evaluate(() => {
|
||
const r = window.Zwischenraum.imRahmen;
|
||
return { mitte: r({ x: 240, y: 120, width: 160, height: 200 }, 640, 480), rand: r({ x: 0, y: 120, width: 100, height: 140 }, 640, 480),
|
||
winzig: r({ x: 310, y: 230, width: 30, height: 30 }, 640, 480), unten: r({ x: 260, y: 400, width: 120, height: 80 }, 640, 480), ohneMass: r({ x: 1, y: 1, width: 1, height: 1 }, 0, 0) };
|
||
});
|
||
ok(rahmenFaelle.mitte === true && rahmenFaelle.rand === false && rahmenFaelle.winzig === false && rahmenFaelle.unten === false && rahmenFaelle.ohneMass === null,
|
||
`„im Rahmen“ heißt: mittig und nicht winzig (${JSON.stringify(rahmenFaelle)})`);
|
||
ok(bild.kann ? /Gesicht/.test(bild.jetzt) : bild.jetzt === "Kamera an", `in diesem Browser: Erkennung ${bild.kann ? "da" : "nicht da"} → „${bild.jetzt}“`);
|
||
ok(!bild.hinweisDa, "bei gutem Bild steht kein Hinweis auf der Vorschau");
|
||
ok(bild.oval, "der Rahmen zum Ausrichten liegt in der Vorschau");
|
||
ok(/reicht für dein Kamerabild/.test(bild.leitungGut[1]) && bild.leitungKnapp[0] === "knapp" && bild.leitungSchwach[0] === "schwach",
|
||
`die Leitung in Worten: „${bild.leitungGut[1]}“`);
|
||
/* Der Hinweis im Bild wirklich gezeichnet – mit einem Gegenlicht-Bild als Kamera. */
|
||
const hinweisGezeichnet = await gast.seite.evaluate(async () => {
|
||
const v = document.getElementById("bz-vorschau");
|
||
const alt = v.srcObject;
|
||
const c = document.createElement("canvas"); c.width = 320; c.height = 180;
|
||
const g = c.getContext("2d");
|
||
const malen = () => { g.fillStyle = "rgb(225,225,225)"; g.fillRect(0, 0, 320, 180); g.fillStyle = "rgb(55,55,55)"; g.fillRect(110, 35, 100, 110); };
|
||
malen();
|
||
const s = c.captureStream(10);
|
||
const uhr = setInterval(malen, 100);
|
||
const orig = window.SaalKamera.strom;
|
||
const echteSpur = alt.getVideoTracks()[0];
|
||
const fake = new MediaStream([s.getVideoTracks()[0], ...alt.getAudioTracks()]);
|
||
window.SaalKamera.strom = () => fake;
|
||
await new Promise((r) => setTimeout(r, 2600));
|
||
const h = document.getElementById("bz-bildhinweis");
|
||
const r = h.getBoundingClientRect();
|
||
const ergebnis = { text: h.textContent, da: !h.hidden && r.height > 0, licht: document.querySelector('#bz-gast .bz-schritt[data-schritt="licht"]')?.textContent.trim() };
|
||
window.SaalKamera.strom = orig;
|
||
clearInterval(uhr);
|
||
s.getTracks().forEach((t) => t.stop());
|
||
void echteSpur;
|
||
await new Promise((r) => setTimeout(r, 2600));
|
||
ergebnis.danach = document.getElementById("bz-bildhinweis").hidden;
|
||
return ergebnis;
|
||
});
|
||
console.log(" Hinweis im Bild:", JSON.stringify(hinweisGezeichnet));
|
||
ok(hinweisGezeichnet.da && hinweisGezeichnet.text === "Gegenlicht" && /^Gegenlicht/.test(hinweisGezeichnet.licht || ""),
|
||
"mit Gegenlicht vor der Kamera steht „Gegenlicht“ auf der Vorschau und im Schritt Licht");
|
||
ok(hinweisGezeichnet.danach, "und verschwindet wieder, sobald das Bild stimmt");
|
||
ok(!geometrie.klein.length, `keine Schrift unter 11,5 px (${geometrie.klein.join(", ")})`);
|
||
|
||
/* ---- Bereit + Draht ---- */
|
||
/* Mitschreiber auf der Regieseite: Die Ansage steht nur 6 s da. */
|
||
await regie.seite.evaluate(() => {
|
||
window.__ansagen = [];
|
||
new MutationObserver(() => { const t = document.getElementById("bz-regie-sagt")?.textContent; if (t) window.__ansagen.push(t); })
|
||
.observe(document.body, { subtree: true, childList: true, characterData: true });
|
||
});
|
||
await regie.seite.waitForSelector("#bz-regie:not([hidden]) .bz-warte", { timeout: 15000 }).catch(() => {});
|
||
await gast.seite.click("#bz-bereit");
|
||
await gast.seite.waitForFunction(() => document.getElementById("bz-bereit")?.getAttribute("aria-pressed") === "true", null, { timeout: 5000 }).catch(() => {});
|
||
ok(await gast.seite.evaluate(() => document.getElementById("bz-bereit")?.getAttribute("aria-pressed") === "true"), "„Ich bin bereit“ ist angekommen");
|
||
await gast.seite.fill("#bz-draht-text", "Bin gleich so weit, Kopfhörer sind drin.");
|
||
await gast.seite.click("#bz-draht-form button[type=submit]");
|
||
await gast.seite.waitForTimeout(800);
|
||
if (BILDER) await gast.seite.locator("#bz-gast").screenshot({ path: `${BILDER}/zwischenraum-gast-1280.png` });
|
||
if (BILDER) await gast.seite.screenshot({ path: `${BILDER}/zwischenraum-gast-1280-ganz.png` });
|
||
|
||
/* ---- Die Regie ---- */
|
||
await regie.seite.evaluate(() => window.Backstage?.holen?.());
|
||
await regie.seite.waitForSelector("#bz-regie:not([hidden]) .bz-warte", { timeout: 15000 }).catch(() => {});
|
||
await regie.seite.waitForFunction(() => document.querySelector(".bz-warte")?.dataset.bereit === "ja"
|
||
&& [...document.querySelectorAll(".bz-warte .bz-wert")].every((w) => w.dataset.stufe !== "offen"), null, { timeout: 15000 }).catch(() => {});
|
||
const karte = await regie.seite.evaluate(() => {
|
||
const li = document.querySelector(".bz-warte");
|
||
if (!li) return null;
|
||
const r = li.getBoundingClientRect();
|
||
return { name: li.querySelector(".bz-warte__name")?.textContent, bereit: li.querySelector(".bz-warte__bereit")?.textContent,
|
||
werte: [...li.querySelectorAll(".bz-wert")].map((w) => `${w.dataset.stufe}:${w.textContent.trim()}`),
|
||
draht: li.querySelector(".bz-draht__liste")?.textContent, hoehe: r.height, sichtbar: r.height > 0 && r.width > 0,
|
||
knopf: li.querySelector(".bz-holen")?.getBoundingClientRect().height || 0 };
|
||
});
|
||
console.log(" Regie-Karte:", JSON.stringify(karte));
|
||
const ansage = await regie.seite.evaluate(() => window.__ansagen || []);
|
||
ok(!(karte?.werte || []).some((w) => /Zu dunkel/.test(w)), "die erste Meldung an die Regie ist eingeschwungen (kein „zu dunkel“ vom Kamerastart)");
|
||
ok(karte?.sichtbar && karte.name === "Nachtfalter" && /bereit/.test(karte.bereit || ""), "die Regie sieht Nachtfalter im Backstage, bereit ✓");
|
||
ok(ansage.some((t) => /Nachtfalter ist bereit\./.test(t)), `die Regie bekommt „Nachtfalter ist bereit.“ angesagt (${JSON.stringify(ansage)})`);
|
||
ok((karte?.werte || []).length === 5 && karte.werte.every((w) => !w.startsWith("offen")), "mit allen fünf Werten");
|
||
ok(/Kopfhörer sind drin/.test(karte?.draht || ""), "und seinem Zuruf");
|
||
/* DIESELBEN STUFEN BEI BEIDEN – nach höchstens drei Sekunden. */
|
||
await regie.seite.waitForTimeout(3500);
|
||
await regie.seite.evaluate(() => window.Backstage?.holen?.());
|
||
await regie.seite.waitForTimeout(600);
|
||
const beiGast = await gast.seite.evaluate(() => [...document.querySelectorAll("#bz-gast .bz-schritt")].map((li) => li.dataset.stufe).join(","));
|
||
const beiRegie = await regie.seite.evaluate(() => [...document.querySelectorAll(".bz-warte .bz-wert")].map((w) => w.dataset.stufe).join(","));
|
||
ok(beiGast === beiRegie, `die Regie sieht dieselben Stufen wie der Gast (Gast ${beiGast} · Regie ${beiRegie})`);
|
||
const ecke = await regie.seite.evaluate(() => document.getElementById("cockpit-backstage")?.getBoundingClientRect().toJSON());
|
||
if (BILDER && ecke) await regie.seite.screenshot({ path: `${BILDER}/zwischenraum-regie-1440.png`, clip: { x: 0, y: Math.max(0, ecke.y - 70), width: 1440, height: Math.min(900 - Math.max(0, ecke.y - 70), ecke.height + 160) } });
|
||
if (BILDER) await regie.seite.screenshot({ path: `${BILDER}/zwischenraum-regie-1440-ganz.png` });
|
||
const pult = await regie.seite.evaluate(() => {
|
||
const p = document.getElementById("pult").getBoundingClientRect();
|
||
const bs = document.getElementById("cockpit-backstage").getBoundingClientRect();
|
||
const innen = document.getElementById("pult-innen")?.getBoundingClientRect();
|
||
const kopf = document.querySelector(".bz-warte__kopf").getBoundingClientRect();
|
||
const holen = document.querySelector(".bz-warte .bz-holen").getBoundingClientRect();
|
||
const zuletzt = document.querySelector(".bz-warte__zuletzt")?.textContent || "";
|
||
return { innen: innen?.height || 0, bsUnten: bs.bottom, pultUnten: p.bottom, kopfH: kopf.height, holenDa: holen.height > 0 && holen.bottom <= bs.bottom + 1 && holen.top >= bs.top - 1, zuletzt };
|
||
});
|
||
console.log(" Pult:", JSON.stringify(pult));
|
||
ok(pult.innen >= 100 && pult.bsUnten <= pult.pultUnten + 1, `die Backstage-Zeile bleibt im Pult, der Regie-Inhalt behält Platz (${Math.round(pult.innen)} px, Zeile endet ${Math.round(pult.bsUnten)} ≤ ${Math.round(pult.pultUnten)})`);
|
||
ok(pult.holenDa && pult.kopfH <= 60, `„Auf die Bühne“ steht zugeklappt in einer Zeile mit Name und Werten (${Math.round(pult.kopfH)} px)`);
|
||
ok(/Kopfhörer sind drin/.test(pult.zuletzt), "der letzte Zuruf steht auch zugeklappt da");
|
||
await regie.seite.click(".bz-warte__auf");
|
||
await regie.seite.waitForTimeout(300);
|
||
const auf = await regie.seite.evaluate(() => ({ innen: document.getElementById("pult-innen").getBoundingClientRect().height,
|
||
bsUnten: document.getElementById("cockpit-backstage").getBoundingClientRect().bottom, pultUnten: document.getElementById("pult").getBoundingClientRect().bottom,
|
||
rollt: document.getElementById("cockpit-backstage").scrollHeight > document.getElementById("cockpit-backstage").clientHeight }));
|
||
ok(auf.innen >= 100 && auf.bsUnten <= auf.pultUnten + 1, `aufgeklappt rollt die Zeile in sich, der Regie-Inhalt behält Platz (${Math.round(auf.innen)} px, rollt=${auf.rollt})`);
|
||
await regie.seite.locator(".bz-warte .bz-draht__feld").scrollIntoViewIfNeeded();
|
||
await regie.seite.fill(".bz-warte .bz-draht__feld", "Super, in einer Minute holen wir dich.");
|
||
await regie.seite.click(".bz-warte .bz-draht__form button[type=submit]");
|
||
await gast.seite.waitForFunction(() => /in einer Minute/.test(document.getElementById("bz-draht")?.textContent || ""), null, { timeout: 8000 }).catch(() => {});
|
||
ok(await gast.seite.evaluate(() => /in einer Minute/.test(document.getElementById("bz-draht")?.textContent || "")), "der Gast liest die Antwort der Regie ohne Neuladen");
|
||
|
||
/* ---- Die Regie am Handy (VanVan, 390 × 844) ---- */
|
||
{
|
||
const vh = await als("hand", 390, 844);
|
||
await vh.seite.waitForTimeout(2500); /* die Eröffnungsblende (1,85 s) ist vorbei */
|
||
await vh.seite.evaluate(() => { const p = document.getElementById("pult"); if (p && p.dataset.auf !== "ja") document.getElementById("pult-griff")?.click(); });
|
||
await vh.seite.waitForSelector("#bz-regie:not([hidden]) .bz-warte", { timeout: 15000 }).catch(() => {});
|
||
await vh.seite.locator(".bz-warte .bz-holen").scrollIntoViewIfNeeded().catch(() => {});
|
||
await vh.seite.waitForTimeout(300);
|
||
const hm = await vh.seite.evaluate(() => {
|
||
const k = document.querySelector(".bz-warte .bz-holen")?.getBoundingClientRect();
|
||
const li = document.querySelector(".bz-warte")?.getBoundingClientRect();
|
||
return { da: !!(k && k.height > 0), hoehe: k?.height || 0, imFenster: !!(k && k.left >= 0 && k.right <= innerWidth && k.top >= 0 && k.bottom <= innerHeight),
|
||
karte: li ? Math.round(li.width) : 0, quer: document.documentElement.scrollWidth - innerWidth };
|
||
});
|
||
console.log(" Regie am Handy:", JSON.stringify(hm));
|
||
ok(hm.da && hm.imFenster && hm.hoehe >= 44, `VanVan erreicht „Auf die Bühne“ am Handy (${Math.round(hm.hoehe)} px hoch, im Fenster=${hm.imFenster})`);
|
||
ok(hm.quer <= 0, `und nichts rollt seitlich (${hm.quer} px)`);
|
||
if (BILDER) await vh.seite.screenshot({ path: `${BILDER}/zwischenraum-regie-handy-390.png` });
|
||
ok(!vh.konsole.length, `Regie am Handy: keine Fehler in der Konsole (${vh.konsole.slice(0, 3).join(" | ")})`);
|
||
await vh.kontext.close();
|
||
}
|
||
|
||
/* ---- Auf die Bühne ---- */
|
||
await regie.seite.click(".bz-warte .bz-holen");
|
||
await gast.seite.waitForFunction(() => document.getElementById("bz-gast")?.hidden === true, null, { timeout: 10000 }).catch(() => {});
|
||
await gast.seite.waitForTimeout(1500);
|
||
const danach = await gast.seite.evaluate(() => ({ zu: document.getElementById("bz-gast")?.hidden === true,
|
||
karte: !!document.getElementById("bs-karte") && !document.getElementById("bs-karte").hidden,
|
||
kameraLebt: (window.SaalKamera?.strom?.()?.getTracks?.() || []).some((t) => t.readyState === "live") }));
|
||
const lage2 = (await roh("/workspace/api/reaktion", { keks: k.admin })).j;
|
||
ok((lage2?.gaeste || []).some((g) => g.id === IDS.gast), "nach „Auf die Bühne“ steht er auf der Bühne");
|
||
ok(danach.zu && danach.karte, "sein Backstage ist zu, die Bühnenkarte („Regie sieht dich …“) steht da");
|
||
ok(danach.kameraLebt, "und seine Kamera läuft weiter – sie wird jetzt gebraucht");
|
||
ok(await regie.seite.evaluate(() => document.getElementById("bz-regie")?.hidden === true), "bei der Regie ist der Backstage leer");
|
||
|
||
/* ---- Handy: Lenny, und dann aus dem Backstage genommen ---- */
|
||
const handy = await als("gast2", 390, 844);
|
||
await roh("/workspace/api/reaktion/gast", { method: "POST", keks: k.admin, rumpf: { person_id: IDS.gast2 } });
|
||
await handy.seite.waitForSelector("#vorraum:not([hidden])", { timeout: 15000 });
|
||
await handy.seite.waitForTimeout(1200);
|
||
await handy.seite.tap("#vorraum-ja");
|
||
await handy.seite.waitForSelector("#bz-gast:not([hidden])", { timeout: 15000 }).catch(() => {});
|
||
await handy.seite.waitForFunction(() => [...document.querySelectorAll("#bz-gast .bz-schritt")].every((li) => li.dataset.stufe !== "offen"), null, { timeout: 12000 }).catch(() => {});
|
||
const hm = await handy.seite.evaluate(() => {
|
||
const zr = document.getElementById("bz-gast").getBoundingClientRect();
|
||
const liste = document.getElementById("chat-liste")?.getBoundingClientRect();
|
||
const knoepfe = [...document.querySelectorAll("#bz-gast button, #bz-gast input")].map((e) => e.getBoundingClientRect().height);
|
||
const b = document.getElementById("bz-bereit").getBoundingClientRect();
|
||
return { hoehe: zr.height, unten: zr.bottom, fenster: innerHeight, chat: liste?.height || 0, kleinsteZiel: Math.min(...knoepfe), breiter: document.documentElement.scrollWidth > innerWidth + 1,
|
||
bereitSichtbar: b.top >= zr.top && b.bottom <= zr.bottom + 1 && b.bottom <= innerHeight };
|
||
});
|
||
console.log(" Handy:", JSON.stringify(hm));
|
||
ok(hm.hoehe > 100 && hm.hoehe <= 0.63 * hm.fenster + 1, `am Handy nimmt der Backstage höchstens 62 % der Höhe (${Math.round(hm.hoehe)} von ${hm.fenster})`);
|
||
ok(hm.kleinsteZiel >= 44, `jedes Tippziel ist mindestens 44 px hoch (${Math.round(hm.kleinsteZiel)})`);
|
||
ok(!hm.breiter, "nichts ragt seitlich hinaus");
|
||
ok(hm.chat >= 100, `am Handy bleibt vom Chat genug stehen (${Math.round(hm.chat)} px)`);
|
||
ok(hm.bereitSichtbar, "„Ich bin bereit“ ist am Handy ohne Rollen zu sehen");
|
||
if (BILDER) await handy.seite.screenshot({ path: `${BILDER}/zwischenraum-handy-390.png` });
|
||
await roh(`/workspace/api/reaktion/gast/${IDS.gast2}`, { method: "DELETE", keks: k.admin });
|
||
await handy.seite.waitForFunction(() => document.getElementById("bz-gast")?.hidden === true, null, { timeout: 10000 }).catch(() => {});
|
||
await handy.seite.waitForTimeout(600);
|
||
const raus = await handy.seite.evaluate(() => ({ zu: document.getElementById("bz-gast")?.hidden === true, strom: window.SaalKamera?.strom?.() || null }));
|
||
ok(raus.zu && raus.strom === null, "aus dem Backstage genommen: Feld zu UND Kamera aus (kein Lämpchen neben einer Seite, die nichts sendet)");
|
||
|
||
for (const [wer, s] of [["Regie", regie], ["Gast", gast], ["Handy", handy]]) {
|
||
ok(!s.konsole.length, `${wer}: keine Fehler in der Konsole (${s.konsole.slice(0, 3).join(" | ")})`);
|
||
}
|
||
await browser.close();
|
||
vorbau.close();
|
||
console.log(`\n${geprueft} Pruefungen, ${fehler} Fehler`);
|
||
try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ }
|
||
process.exit(fehler ? 1 : 0);
|