Files
dogfather-universe/server/pruef-saal-handy.mjs
T
DogFatherGitandClaude Opus 5.5 cba225932f Saal am Handy: mehr Chat, LIVE im Chat-Kopf, Faehrte im Kopf, Ziel/Werbung im Wechsel auf kurzen Handys, Einlauf blitzt nicht nach
Chat sichtbar (Reaction = Zocken): iPhone SE 174 px, kleines Android 256,
iPhone 14 293, grosses Android 351 (vorher 47/129/216/274).
Neue Pruefung pruef-saal-chat (73), pruef-saal-handy an das neue Bild angepasst (24).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 18:46:44 +01:00

281 lines
17 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* =====================================================================
DER SAAL AM HANDY — Video frei, Infos darunter (28.10.2026)
Filipe, mit einem Bildschirmfoto vom Handy: „das bild auf dem handy
muss perfektioniert werden, den wenn ich werbung oder ziele drauf habe
soll es so sein dass es auch auf dem handy geil ist und das video immer
noch gut zu sehen ist. auch dieses auf sendung 3 dabei … passt nicht
dahin. der ganze chat und bildschirm muss wirklich perfekt sein.“
Nachgestellt wird GENAU sein Bild: Reaction live, Werbeband im Wechsel
mit Rabattcode, der Häkelhase in der Ecke oben links, eine Ziel-Karte,
drei Leute dabei. Gemessen wird nicht „ist etwas da“, sondern WO:
Handy hochkant Über dem Video liegt keine Info mehr (Schild,
Ziel-Karte, Band, Eckbild); sie stehen in der
Leiste DARUNTER, „Live“ steht (seit der zweiten
Runde) mit rotem Punkt in der Chat-Überschrift,
und der Chat behält Platz.
Handy quer alles wie vorher über dem Bild (Leiste weg).
Rechner unverändert, Leiste weg.
Aufrufen mit: node server/pruef-saal-handy.mjs
===================================================================== */
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-saal-handy-"));
process.env.WORKSPACE_DB = join(ordner, "workspace.db");
const PORT = await eigenerPort(import.meta);
const HTTPS_PORT = await eigenerPort(import.meta, "pruef-saal-handy (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;
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(240_000, "pruef-saal-handy");
await new Promise((r) => setTimeout(r, 1000));
const CREW = "crew.dogfather-universe.com";
let fehler = 0, geprueft = 0;
const ok = (b, t) => { geprueft++; console.log((b ? " ok " : " FEHL ") + t); if (!b) fehler++; };
const melde = (t) => console.log(t);
process.on("exit", () => { try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ } });
function nichtNachsehbar(grund) {
console.log(`\n -- NICHT NACHSEHBAR\n ${grund}\n Das ist KEIN Befund am Code.\n`);
process.exit(3);
}
/* ---------- 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);
return d.prepare("SELECT last_insert_rowid() AS id").get().id;
}
const CODES = { admin: "CODE-H90-000001", gast: "CODE-H91-000001" };
anlegen("DogFather", "admin", CODES.admin);
anlegen("Nachtfalter", "gast", CODES.gast);
const weitere = [anlegen("Luna", "gast", "CODE-H92-000001"), anlegen("Mo", "gast", "CODE-H93-000001")];
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, code: CODES[wer], alter_ok: true } });
return [].concat(a.kopf["set-cookie"] || []).map((z) => z.split(";")[0]).join("; ");
}
const k = { admin: await anmelden("admin"), gast: await anmelden("gast") };
if (!k.admin || !k.gast) nichtNachsehbar("Die Anmeldung klappt nicht.");
/* ---------- Filipes Bild: Reaction live, Werbung, Hase, Ziel, 3 dabei --- */
await roh("/workspace/api/reaktion", { method: "PUT", keks: k.admin,
rumpf: { titel: "Reaction", video: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" } });
for (const st of ["vorbereitung", "live"]) {
const a = await roh("/workspace/api/reaktion/stand", { method: "POST", keks: k.admin, rumpf: { stand: st } });
if (a.code >= 400) nichtNachsehbar(`Der Saal lässt sich nicht auf „${st}“ stellen (HTTP ${a.code}).`);
}
let a = await roh("/workspace/api/reaktion/werbung", { method: "POST", keks: k.admin, rumpf: { art: "wechsel", ecke_hase: "ol" } });
ok(a.code === 200, `Werbung: Wechsel mit Häkelhase oben links (${a.code})`);
const banner = d.prepare("SELECT COUNT(*) AS n FROM reaktion_banner WHERE aktiv = 1").get().n;
ok(banner >= 1, `Voraussetzung: mindestens eine Botschaft im Band (${banner})`);
a = await roh("/workspace/api/serverziele", { method: "POST", keks: k.admin,
rumpf: { titel: "Deranged", text: "Ein neues Auto für die Stadt.", kategorie: "fahrzeug", format: "kompakt", ziel: "30", aktiv: true } });
ok(a.code === 201, `ein Server-Ziel „Deranged“ (${a.code})`);
a = await roh("/workspace/api/serverziele/anzeige", { method: "POST", keks: k.admin, rumpf: { anzeige: "rotation", platz: "or" } });
ok(a.code === 200, `Ziele im Wechsel, oben rechts (${a.code})`);
for (const id of weitere) {
d.prepare("INSERT OR REPLACE INTO reaktion_dabei (person_id, seit, gesehen) VALUES (?,?,?)").run(id, new Date().toISOString(), new Date().toISOString());
}
/* ---------- Browser ----------------------------------------------------- */
const sd = join(ordner, "p.key"), zd = join(ordner, "p.crt");
try { zertifikatBauen(sd, zd, CREW); } catch (f) { nichtNachsehbar(`Kein Zertifikat: ${f?.message}`); }
const vorbau = httpsServer({ key: readFileSync(sd), cert: readFileSync(zd) }, (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 { chromium } = await import("playwright");
const browser = await chromium.launch({ args: [`--host-resolver-rules=MAP ${CREW} 127.0.0.1`, "--ignore-certificate-errors"] });
async function saal(breite, hoehe) {
const kontext = await browser.newContext({ viewport: { width: breite, height: hoehe }, hasTouch: breite <= 860, isMobile: breite <= 860 && hoehe > breite });
await kontext.addCookies(k.gast.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/i.test(m.text())) konsole.push(m.text()); });
seite.on("response", (x) => { if (x.status() >= 400 && !/ytimg\.com|youtube/.test(x.url())) konsole.push(`${x.status()} ${x.url().replace(/^https?:\/\/[^/]+/, "")}`); });
await seite.goto(`${BASIS}/workspace/reaktion.html`, { waitUntil: "domcontentloaded" });
/* Warten auf eine gemessene Eigenschaft: Band UND Ziel-Karte sind da. */
await seite.waitForFunction(() => document.querySelector(".werbung")?.dataset.art === "wechsel"
&& document.querySelector(".sziel")?.dataset.an === "ja", null, { timeout: 15000 }).catch(() => {});
/* Der Einlauf (CSS-Inszenierung beim Betreten) liegt anfangs deckend
über allem -- erst wenn er weg ist, zeigt ein Foto den Saal. */
await seite.waitForFunction(() => { const e = document.getElementById("einlauf");
return !e || e.hidden || getComputedStyle(e).visibility === "hidden"; }, null, { timeout: 15000 }).catch(() => {});
await seite.waitForTimeout(800);
return { kontext, seite, konsole };
}
/** Was liegt WO — alles in Bildschirmpunkten. */
const messen = (seite) => seite.evaluate(() => {
const r = (e) => { if (!e) return null; const b = e.getBoundingClientRect(); return b.width < 2 || b.height < 2 ? null : { x: b.left, y: b.top, r: b.right, b: b.bottom, w: b.width, h: b.height }; };
const sichtbar = (e) => { if (!e) return false; const c = getComputedStyle(e); return c.display !== "none" && c.visibility !== "hidden" && Number(c.opacity) > 0.05 && !!r(e); };
const lw = r(document.getElementById("leinwand"));
const teile = {
schild: document.getElementById("schild"),
ziel: document.querySelector(".sziel .szk[data-sichtbar='ja']"),
band: document.querySelector(".werbung__band:not([hidden])"),
ecke: document.querySelector(".werbung__ecke:not([hidden])"),
};
const ueberVideo = Object.entries(teile).filter(([, e]) => sichtbar(e) && lw && (() => {
const q = r(e); return Math.min(q.r, lw.r) - Math.max(q.x, lw.x) > 2 && Math.min(q.b, lw.b) - Math.max(q.y, lw.y) > 2;
})()).map(([n]) => n);
const info = document.getElementById("saalinfo");
const chat = r(document.getElementById("chat-liste"));
return {
lw, ueberVideo,
info: sichtbar(info) ? r(info) : null,
zielIn: !!document.querySelector("#saalinfo-ziel .sziel"), werbungIn: !!document.querySelector("#saalinfo-werbung .werbung"),
zielR: sichtbar(teile.ziel) ? r(teile.ziel) : null, bandR: sichtbar(teile.band) ? r(teile.band) : null, kamR: [...document.querySelectorAll("#kameras .kamera")].map(r).filter(Boolean), eckeR: sichtbar(teile.ecke) ? r(teile.ecke) : null,
schildSichtbar: sichtbar(teile.schild),
/* „Live“ steht seit der zweiten Runde in der Chat-Überschrift (roter
Punkt), die Zahl daneben im Chat-Kopf (👥 3). */
titelLive: (() => { const t = document.querySelector(".schiene__titel"); return !!t && getComputedStyle(t, "::before").content !== "none"; })(),
chatZahl: document.getElementById("chat-leute-zahl")?.textContent.trim(),
/* Roh, ohne Blick auf die Deckkraft: Auf kurzen Handys wechseln sich
Karte und Band im selben Feld ab — eins ist dann gerade unsichtbar. */
zielRoh: r(teile.ziel), bandRoh: r(teile.band),
wechsel: [document.getElementById("saalinfo-ziel"), document.getElementById("saalinfo-werbung")].map((e) => e && getComputedStyle(e).animationName),
schildZahl: document.getElementById("schild-zahl")?.textContent.trim(),
code: !!document.querySelector("#saalinfo-werbung .werbung__code"),
chatH: chat ? Math.round(chat.h) : 0,
breit: document.documentElement.scrollWidth <= innerWidth,
};
});
melde("\n=== Handy hochkant (390 × 844) ===");
{
const s = await saal(390, 844);
const m = await messen(s.seite);
ok(!!m.lw && m.lw.w >= 380, `das Video steht in voller Breite (${m.lw && `${Math.round(m.lw.w)}×${Math.round(m.lw.h)}`})`);
ok(m.ueberVideo.length === 0, `über dem Video liegt keine Info mehr (${m.ueberVideo.join(", ") || "frei"})`);
ok(!!m.info && m.info.y >= m.lw.b - 1, `die Info-Leiste steht direkt unter dem Video (oben ${m.info && Math.round(m.info.y)}, Video unten ${m.lw && Math.round(m.lw.b)})`);
ok(m.zielIn && !!m.zielR && m.zielR.y >= m.lw.b - 1, "die Ziel-Karte steht in der Leiste");
ok(m.werbungIn && !!m.bandR && m.bandR.y >= m.lw.b - 1 && m.code, "das Werbeband mit Rabattcode steht in der Leiste");
ok(!!m.info && !m.schildSichtbar && m.titelLive && m.chatZahl === m.schildZahl.replace(/\D/g, ""),
`statt des Schilds: „LIVE“ mit rotem Punkt im Chat-Kopf, ${m.chatZahl} dabei (Schild sagte „${m.schildZahl}“)`);
ok(m.chatH >= 250, `der Chat behält Platz (${m.chatH} px)`);
ok(m.breit, "nichts läuft seitlich hinaus");
ok(s.konsole.length === 0, `keine Fehler in der Konsole (${s.konsole.slice(0, 3).join(" | ") || "keine"})`);
await s.seite.screenshot({ path: join(HIER, "pruef-saal-handy-hoch.png") });
/* DREHEN: quer wandert alles zurück über das Bild — ohne Neuladen. */
await s.seite.setViewportSize({ width: 844, height: 390 });
await s.seite.waitForTimeout(900);
const q = await messen(s.seite);
ok(!q.info && !q.zielIn && !q.werbungIn && q.schildSichtbar, `quer gedreht: Leiste weg, alles wieder über dem Bild, Schild da (${q.ueberVideo.join(", ")})`);
const kamUnterBand = q.kamR.filter((c) => q.bandR && Math.min(c.b, q.bandR.b) - Math.max(c.y, q.bandR.y) > 2 && Math.min(c.r, q.bandR.r) - Math.max(c.x, q.bandR.x) > 2).length;
ok(q.kamR.length > 0 && kamUnterBand === 0, `quer: kein Kamerafenster unter dem Band (${q.kamR.length} Fenster, ${kamUnterBand} verdeckt)`);
ok(!!q.bandR && q.bandR.h <= 46 && !!q.eckeR && q.eckeR.h <= 60,
`quer: Band und Häkelhase klein genug fürs flache Bild (Band ${q.bandR && Math.round(q.bandR.h)} px, Hase ${q.eckeR && Math.round(q.eckeR.h)} px, Video ${q.lw && Math.round(q.lw.h)} px hoch)`);
await s.seite.screenshot({ path: join(HIER, "pruef-saal-handy-quer.png") });
await s.seite.setViewportSize({ width: 390, height: 844 });
await s.seite.waitForTimeout(900);
const z = await messen(s.seite);
ok(!!z.info && z.zielIn && z.werbungIn && z.ueberVideo.length === 0, "und wieder hochkant: zurück in die Leiste");
await s.kontext.close();
}
melde("\n=== Schmales Handy (360 × 740) ===");
{
const s = await saal(360, 740);
const m = await messen(s.seite);
ok(m.ueberVideo.length === 0 && !!m.info && m.breit && !!m.zielRoh && m.zielRoh.r <= 360 && !!m.bandRoh && m.bandRoh.r <= 360,
`360 Punkte: Video frei, Leiste da, Karte und Band enden im Bild (Karte bis ${m.zielRoh && Math.round(m.zielRoh.r)}, Band bis ${m.bandRoh && Math.round(m.bandRoh.r)})`);
/* KURZES HANDY (740 hoch): Karte und Band teilen sich EINE Zeile und
wechseln sich ab. Geprüft wird beides: dieselbe Zeile UND dass der
Wechsel wirklich umschaltet (die Animation wird vorgespult, nicht
abgewartet). */
ok(!!m.zielRoh && !!m.bandRoh && Math.abs(m.zielRoh.y - m.bandRoh.y) <= 4 && m.wechsel.join() === "saalinfo-zuerst,saalinfo-danach",
`kurzes Handy: Karte und Band in EINER Zeile im Wechsel (${m.wechsel.join(" / ")})`);
const umschalten = await s.seite.evaluate(() => {
const deck = () => ["saalinfo-ziel", "saalinfo-werbung"].map((id) => Number(getComputedStyle(document.getElementById(id)).opacity).toFixed(2)).join("/");
const anims = ["saalinfo-ziel", "saalinfo-werbung"].map((id) => document.getElementById(id).getAnimations()[0]);
if (anims.some((x) => !x)) return { vorher: deck(), nachher: "keine Animation" };
anims.forEach((x) => { x.pause(); x.currentTime = 2000; });
const vorher = deck();
anims.forEach((x) => { x.currentTime = 10000; });
const nachher = deck();
anims.forEach((x) => x.play());
return { vorher, nachher };
});
ok(umschalten.vorher === "1.00/0.00" && umschalten.nachher === "0.00/1.00",
`der Wechsel schaltet um: nach 2 s ${umschalten.vorher}, nach 10 s ${umschalten.nachher} (Karte/Band)`);
ok(m.chatH >= 200, `der Chat behält Platz (${m.chatH} px)`);
await s.seite.screenshot({ path: join(HIER, "pruef-saal-handy-schmal.png") });
await s.kontext.close();
}
melde("\n=== Rechner (1400 × 900): wie bisher ===");
{
const s = await saal(1400, 900);
const m = await messen(s.seite);
ok(!m.info && !m.zielIn && !m.werbungIn && m.schildSichtbar, "am Rechner keine Leiste, Karte und Band über dem Bild, Schild da");
const verdeckt = m.kamR.filter((c) => m.bandR && Math.min(c.b, m.bandR.b) - Math.max(c.y, m.bandR.y) > 2 && Math.min(c.r, m.bandR.r) - Math.max(c.x, m.bandR.x) > 2).length;
ok(m.kamR.length > 0 && !!m.bandR && verdeckt === 0, `am Rechner: kein Kamerafenster unter dem Band (${m.kamR.length} Fenster, ${verdeckt} verdeckt)`);
ok(s.konsole.length === 0, `keine Fehler in der Konsole (${s.konsole.slice(0, 3).join(" | ") || "keine"})`);
await s.kontext.close();
}
await browser.close();
vorbau.close();
melde(`\n${geprueft} Prüfungen, ${fehler} Fehler`);
console.log(fehler ? "NICHT IN ORDNUNG" : "ALLES IN ORDNUNG");
process.exit(fehler ? 1 : 0);